I'm having an issue with StreamWriter and I just can't find what I'm doing wrong.
String line, new_line;
using (StreamReader sr = new StreamReader(txtFilePath.Text))
{
using (StreamWriter sw = new StreamWriter(txtResultFolder.Text.ToString() + "\\" + "NEW_trimmed_file" + ".csv", true))
{
while ((line = sr.ReadLine()) != null)
{
new_line = line.TrimEnd();
MessageBox.Show(new_line);
sw.WriteLine(new_line);
}
}
}
I used the MessageBox.Show(new_line), just to be sure I have a value for the StreamWriter to write, but in the resulted file I cannot find anything. As an additional information I have a text which has empty spaces for each line (a lot of spaces) and I'm making another file with same lines as the first, but with no spaces. Any hints why the StreamWriter does not actually writes in the destination file?
Many thanks,