How I can Read this File in C#
-
I Need Read this File (STR) Subtitle File And put all data from File in ListView like this http://www.cpestudents.net/upload/up/sub.gif[^] File http://www.cpestudents.net/upload/up/sub2.gif[^]
-
I Need Read this File (STR) Subtitle File And put all data from File in ListView like this http://www.cpestudents.net/upload/up/sub.gif[^] File http://www.cpestudents.net/upload/up/sub2.gif[^]
Read the textbook again or audit the class
-
I Need Read this File (STR) Subtitle File And put all data from File in ListView like this http://www.cpestudents.net/upload/up/sub.gif[^] File http://www.cpestudents.net/upload/up/sub2.gif[^]
Try this one:
StreamReader s = new StreamReader(@"f:\mytext.txt");
ArrayList a = new ArrayList();
while (s.Peek() >= 0)
{
string alltext = "";
string text = "";
while ((text = s.ReadLine()) != "" && text != null)
{
alltext += ("|" + text);
}
a.Add(alltext);
}s.Close();
foreach (string text in a)
{
string[] splitString = text.Split('|');string tempstring = ""; for (int i = 3; i < splitString.Length; i++) { tempstring += splitString\[i\]; }
ListViewItem lvi = new ListViewItem(new string[] { splitString[1], splitString[2].Substring(0, 12), splitString[2].Substring(17, 12), tempstring });
this.listView1.Items.Add(lvi);
} -
Try this one:
StreamReader s = new StreamReader(@"f:\mytext.txt");
ArrayList a = new ArrayList();
while (s.Peek() >= 0)
{
string alltext = "";
string text = "";
while ((text = s.ReadLine()) != "" && text != null)
{
alltext += ("|" + text);
}
a.Add(alltext);
}s.Close();
foreach (string text in a)
{
string[] splitString = text.Split('|');string tempstring = ""; for (int i = 3; i < splitString.Length; i++) { tempstring += splitString\[i\]; }
ListViewItem lvi = new ListViewItem(new string[] { splitString[1], splitString[2].Substring(0, 12), splitString[2].Substring(17, 12), tempstring });
this.listView1.Items.Add(lvi);
}Wow, nothing like doin' his classwork for him. Now he'll definately fail the class! Dave Kreskowiak Microsoft MVP - Visual Basic