下面的代码读取带有路径标题的文本文件,后跟文件名列表。该代码将每个文件(从第二行开始)添加到 ListView。由于某种原因,最后两行从未到达。有任何想法吗?
private void loadFromFile()
{
if ((faxInOn != null) && File.Exists(@"D:\Settings.ye"))
{
string[] s;
StreamReader sr = new StreamReader(@"D:\Settings.ye", Encoding.Default);
s = sr.ReadToEnd().Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
faxInOn.changePath(s[0]);
foreach (string temp in s)
foreach (ListViewItem lvi in listView1.Items)
if (lvi.Text == temp.Substring(1))
lvi.ImageIndex = int.Parse(temp.Substring(0, 1));
sr.Close();
sr.Dispose();
}
}
谢谢