C# 写日志 Log
public static void WriteLog(string strLog, string name = "Log")
{
string Path = AppDomain.CurrentDomain.BaseDirectory + name;
if (!Directory.Exists(Path))
Directory.CreateDirectory(Path);
Path += "/" + DateTime.Now.ToString("yyyy-MM-dd");
if (!Directory.Exists(Path))
Directory.CreateDirectory(Path);
Path += "/log.txt";
FileStream fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine(DateTime.Now.ToString() + ": " + strLog);
m_streamWriter.Flush();
m_streamWriter.Close();
fs.Close();
}
以上就是短码网小编为大家整理的《C# 写日志 Log》相关内容,希望大家喜欢。
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权/违法违规/事实不符,请将联系本站反馈,一经查实,立即处理!
《C# 写日志 Log》文档下载仅供参考学习,下载后请在24小时内删除。
转载注明出处:https://www.duanma.net/article/6f85f9c8223.html