如何分割導入的文本內容?
listView1.View = View.Details;//設置視圖為詳細信息
ColumnHeader header1 = new ColumnHeader();
header1.Width = 100; //列標頭寬
header1.Text = "第一列"; //列標頭名稱
ColumnHeader header2 = new ColumnHeader();
header2.Width = 100;
header2.Text = "第二列";
listView1.Columns.Add(header1);//添加列
listView1.Columns.Add(header2);
string path = @"G:\2.txt";//文件路徑
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
using (Streamreader reader = new StreamReader(fs, Encoding.Default))
{
string line = reader.ReadLine();
while (line != null)
{
string[] arr = line.Split(new string[] { "----" }, StringSplitOptions.None);
listView1.Items.Add(new ListViewItem(arr));
line = reader.ReadLine();
}
}
}