private static void Log(string content, string fileName="log.txt")
        {
            string logsPath = AppDomain.CurrentDomain.BaseDirectory + "\\App_Code\\logs\\";
            string filename = logsPath + fileName;
            if (!Directory.Exists(logsPath))
                Directory.CreateDirectory(logsPath);
            StreamWriter sr = null;
            try
            {
                if (!File.Exists(filename))
                {
                    sr = File.CreateText(filename);
                }
                else
                {
                    sr = File.AppendText(filename);
                }
                sr.WriteLine(content);
            }
            catch
            {
            }
            finally
            {
                if (sr != null)
                    sr.Close();
            }
        }

  

相关文章:

  • 2022-02-23
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-22
  • 2021-08-02
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案