public static void WriteTextLog(string action, string strMessage, DateTime time)
{
string path = AppDomain.CurrentDomain.BaseDirectory + @"SystemLog";
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
string fileFullPath = path + time.ToString("yyyy-MM-dd") + ".System.txt";
StringBuilder str = new StringBuilder();
str.Append("Time: " + time.ToString() + "
");
str.Append("Action: " + action + "
");
str.Append("Message: " + strMessage + "
");
str.Append("-----------------------------------------------------------
");
StreamWriter sw;
if (!File.Exists(fileFullPath))
{
sw = File.CreateText(fileFullPath);
}
else
{
sw = File.AppendText(fileFullPath);
}
sw.WriteLine(str.ToString());
sw.Close();
}