English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1 answers

This is a little custom method I use to write to a log file in c#. Even if the file "Log.txt" has not been created the method will create it on the fly and then write to it. If it has been created already then it will simply append the new text to the end of the file.

private static void LogEvent(string Event_Msg)
{
//Write Message path to log for testing.
FileInfo Log_File = new FileInfo(App_Path + "\\Log.txt");
StreamWriter Log_Writer = Log_File.AppendText();
Log_Writer.WriteLine( Event_Msg );
Log_Writer.Flush();
Log_Writer.Close();
}

2006-11-28 12:28:16 · answer #1 · answered by Jackson 2 · 0 0

fedest.com, questions and answers