I have a bit of code that works great on smaller files, but when the files are bigger the program locks up - or is just so slow it appears to be - I can walk away for 10 minutes and it's still sitting there. How do I improve the efficiency of this code for larger files? Also, something minor - when it's at the last split, the next item has nothing to split and I end up with a duplicate replace. How do I fix this? The efficiency issue is obviously my main problem here.
for (int i = 0; i < divs.Count; i++)
{
Regex regex = new Regex("</div>");
string[] hands = regex.Split(divs[i].ToString());
string output = string.Empty;
foreach (var item in hands)
{
output += item + "</div>";
string text = File.ReadAllText(strfilename);
text = text.Replace("style = \"#\" >", textBox1.Text);
////style = "#" >
richTextBox1.Text = text;
}
//supposed to output the array to a message box
MessageBox.Show(output);
}