I'm having trouble reading a local file into a string in C #.
Here is what I came up with so far:
string file = @"C:\script_test\{5461EC8C-89E6-40D1-8525-774340083829}.html";
using (StreamReader reader = new StreamReader(file))
{
string line = "";
while ((line = reader.ReadLine()) != null)
{
textBox1.Text += line.ToString();
}
}

And this is the only solution that seems to work.
I tried some other suggested methods for reading a file, for example:
string file = @"C:\script_test\{5461EC8C-89E6-40D1-8525-774340083829}.html";
string html = File.ReadAllText(file).ToString();
textBox1.Text += html;

However, it does not work properly.
Here are the first few lines of the file I'm trying to read:

as you can see, he has some funky characters, to be honest, I don’t know if this strange behavior is the cause.
But in the first case, the code seems to skip these lines, printing only "Document created by Office Communicator ..."
source
share