sarsnake sarsnake - 1 year ago 80
C# Question

StreamWriter.Write doesn't write to file; no exception thrown

My code in C# ( MVC)

StreamWriter tw = new StreamWriter("C:\\mycode\\myapp\\logs\\log.txt");

// write a line of text to the file

The file is created but is empty. No exception is thrown. I have never seen this before and I am stuck here; I just need to write some debugging output.

Please advise.

Answer Source


System.IO.File.WriteAllText(@"path\te.txt", "text");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download