在Server 发布目录上自动创建一个Log 文件夹.里面按日期生成一个txt 文件记log .
 message)
        {
            string varAppPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "log";
            System.IO.Directory.CreateDirectory(varAppPath);
            
string head = System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ":" + System.DateTime.Now.Millisecond.ToString();
            
string logMessage = head + System.Environment.NewLine + message + System.Environment.NewLine;
            
string strDate = System.DateTime.Now.ToString("yyyyMMdd");
            
string strFile = varAppPath + "\\" + strDate + ".log";
            StreamWriter  SW 
= new StreamWriter(strFile, true);
            SW.WriteLine(logMessage);
            SW.Flush();
            SW.Close();
        }

相关文章:

  • 2021-10-07
  • 2021-11-13
  • 2021-06-29
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2021-10-06
  • 2021-12-11
猜你喜欢
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-02-27
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案