Posted By

mracoker on 06/18/10


Tagged

file io c log write


Versions (?)

Simple Log File


 / Published in: C#
 

  1. private void Log(string txt)
  2. {
  3. string logFile = Server.MapPath("/") + "log.txt";
  4.  
  5. // create a writer and open the file
  6. TextWriter tw = new StreamWriter(logFile, true);
  7.  
  8. // write a line of text to the file
  9. tw.WriteLine(DateTime.Now + " >> " + txt);
  10.  
  11. // close the stream
  12. tw.Close();
  13. }

Report this snippet  

You need to login to post a comment.