1、说明:
写入文件内容,如果文件中有内容,则进行追加,目录是程序集下的目录
public static void WriteLog(string value)
{
try
{
//目录是程序集下的Debug目录
string strPath = AppDomain.CurrentDomain.BaseDirectory + "\\Error.txt";
StreamWriter sw = new StreamWriter(strPath, true);
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + " : " + value);
sw.Close();
sw.Dispose();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}