I have hit a mental wall. Basically, this code is supposed to execute and gather all the text files I have in a folder (and eventually update the text box every 10 seconds.)
At the moment, it will only pull text from one or two files at once and that will be it. It will not update this textbox3 either. I was wondering if anyone had any ideas as to why this is happening?
Since I’ve been working with this code for hours I don’t know how clear I am being. If you have any questions about it please feel free to ask. Thanks for looking.
public void read()
{
string[] filePaths = Directory.GetFiles(@"U:\My Documents\chat\", "*.txt",
SearchOption.AllDirectories);
foreach (string file in filePaths)
{
TextReader objstream = new StreamReader(file);
textBox3.Text = objstream.ReadToEnd();
objstream.Close();
textBox3.Select(textBox3.Text.Length, 0);
textBox3.ScrollToCaret();
break;
}
}
instead of
try
edit 1: if you want to refresh this textbox, don’t forget to clear its text before refreshing. (
textBox3.Text = ""will do). you can put this line at the beginning of theread()as well.edit 2: remove
break;line in the for…each loop.