Return to Snippet

Revision: 39631
at January 19, 2011 08:00 by jwwest


Initial Code
public void LogMessageToFile(string msg)
    {
        System.IO.StreamWriter sw = System.IO.File.AppendText("log.txt");
        try
        {
            string logLine = System.String.Format(
                "{0:G}: {1}.", System.DateTime.Now, msg);
            sw.WriteLine(logLine);
        }
        finally
        {
            sw.Close();
        }
    }

Initial URL

                                

Initial Description

                                

Initial Title
Log message to file

Initial Tags

                                

Initial Language
C#