You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
915 B
28 lines
915 B
4 years ago
|
using System;
|
||
|
using System.Configuration;
|
||
|
using System.Globalization;
|
||
|
using System.IO;
|
||
|
using System.Configuration;
|
||
|
namespace AutoFileCopyNet
|
||
|
{
|
||
|
public static class LogFileAccess
|
||
|
{
|
||
|
public static void WriteLogFile(string logMessage)
|
||
|
{
|
||
|
string logfilepath = ConfigurationManager.AppSettings["LOGFILEPATH"].ToString();
|
||
|
if (!Directory.Exists(logfilepath))
|
||
|
{
|
||
|
Directory.CreateDirectory(logfilepath);
|
||
|
}
|
||
|
logfilepath = logfilepath + DateTime.Now.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo) + "log.txt";
|
||
|
|
||
|
StreamWriter sw = new StreamWriter(@logfilepath, true);
|
||
|
|
||
|
//sw.WriteLine("写日志:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo));
|
||
|
sw.WriteLine(logMessage);
|
||
|
sw.Flush();
|
||
|
sw.Close();
|
||
|
}
|
||
|
}
|
||
|
}
|