32 lines
873 B
C#
32 lines
873 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Worklist_SCP
|
|
{
|
|
public static class logger
|
|
{
|
|
|
|
public static void LogWriter(string message)
|
|
{
|
|
string logFilePath = Application.StartupPath + @"\logs.txt";
|
|
// 确保日志文件目录存在
|
|
var logDirectory = Path.GetDirectoryName(logFilePath);
|
|
if (!Directory.Exists(logDirectory))
|
|
{
|
|
Directory.CreateDirectory(logDirectory);
|
|
}
|
|
// 打开文件用于追加
|
|
using (StreamWriter writer = new StreamWriter(logFilePath, true))
|
|
{
|
|
writer.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} - {message}");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|