//一定要引用
using System.IO;
using System.Configuration;
//写入日志文件
public void WriteLoadLogData(string LastUrl)
{
CacheHelper cache = new CacheHelper();
string _file_root_path = ConfigurationManager.AppSettings["PageLogPath"].Trim();
//if (type == "Creating")
_file_root_path = _file_root_path + @"\Creating";
if (!Directory.Exists(_file_root_path))
{
Directory.CreateDirectory(_file_root_path);
}
string path = _file_root_path + @"\" + DateTime.Now.ToString("yyyy-MM-dd") + "Loadlog.txt";
if (!System.IO.File.Exists(path))
{
FileStream stream = System.IO.File.Create(path);
stream.Close();
stream.Dispose();
}
using (StreamWriter writer = new StreamWriter(path, true))
{
writer.WriteLine(DateTime.Now + "异常数据为:" + LastUrl + "\r\n");
}
}
C#写入txt日志
最新推荐文章于 2025-04-03 15:11:18 发布