c# 添加日志
private static void setlog(string message) { string logPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\log\\"; if (!Directory.Exists(logPath))//没有则创建 { Directory.CreateDirectory(logPath); } using (FileStream stream = new FileStream(logPath + DateTime.Now.ToString("yyyyMMddHHmm") + ".txt", FileMode.Append)) using (StreamWriter writer = new StreamWriter(stream)) { writer.WriteLine($"{DateTime.Now}:{message}"); } }