public class Logger
{
public static bool _doLog = true;
public static void Log(String filename, String Message)
{
if (!_doLog)
return;
if (File.Exists(filename))
{
using (StreamWriter sw = File.AppendText(filename))
{
sw.WriteLine(String.Format("{0} : {1}", DateTime.Now, Message));
sw.Close();
}
}
else
{
using (StreamWriter sw = File.CreateText(filename))
{
sw.WriteLine(String.Format("{0} : {1}", DateTime.Now, Message));
sw.Close();
}
}
}
}
I have experience working with C++ and DirectX. I prefer working with C# and WPF. In my spare time I work with HTML, JS, CSS.
Showing posts with label Logger. Show all posts
Showing posts with label Logger. Show all posts
Sunday, May 16, 2010
C# Logger - Write strings to log file
Subscribe to:
Posts (Atom)