Reputation: 97
i have big file with content of merged some other file.
every file have a strings in start of himself
in this code i can catch the index of header
private void button1_Click(object sender, EventArgs e)
{
string s = File.ReadAllText("D:\\test.img");
int i = 0;
while ((i = s.IndexOf("xxxyyyzzz", i)) != -1)
{
listBox1.Items.Add(i);
i++;
}
}
how can split this file with header string ?
Upvotes: 0
Views: 38
Reputation: 972
Doesn't get any simpler than this.
private void button1_Click(object sender, EventArgs e)
{
string s = File.ReadAllText("D:\\test.img");
var array = s.split("xxxyyyzzz", StringSplitOptions.None);
forEach(string s in array)
{
listBox1.Items.Add(s);
}
}
Upvotes: 1