I’m sorry for asking noobish questions, but I am one :).
I can write a .txt file using Write or WriteLine, which reads the whole TextBox. The problem is when I read it. I can not read it using ReadLine. It gives the whole text on one line. It must be a problem with the reading, because in NotePad, I get the file correctly.
What is the reason of this quite strange behavior, and how can I change it?
method containing StreamReader
StreamReader streamreader = new StreamReader(openfiledialog.FileName);
textbox.Text = "";
while (!streamreader.EndOfStream)
{
string read_line = streamreader.ReadLine();
textbox.Text += read_line + "\n";
}
streamreader.Close();
method containing StreamWriter
StreamWriter streamwriter = new StreamWriter(savefiledialog.FileName);
streamwriter.Write(textbox.Text);
streamwriter.Close();
Thanks in advance.
UPDATED: ReadToEnd worked
Without seeing any code the best guess I have is you’re using different line separators between the textbox and the text file.
I’d guess you either need to format the data to make sure the data gets the right separator for the source, or change the newline separator for the textbox.