写日志
public static void WriteLogs(string filename, string type, string content)
{
string path = AppDomain.CurrentDomain.BaseDirectory;
if (!string.IsNullOrEmpty(path))
{
path = AppDomain.CurrentDomain.BaseDirectory + filename;
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
path = path + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
if (!File.Exists(path))
{
FileStream fs = File.Create(path);
fs.Close();
}
if (File.Exists(path))
{
StreamWriter sw = new StreamWriter(path, true, System.Text.Encoding.Default);
sw.WriteLine(DateTime.Now.ToString("yyyyMMdd") + type + "-->" + content);
sw.Close();
}
}
}
Filename 为 文件夹名称

浙公网安备 33010602011771号