?? logger.cs
字號:
?using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Youzi.DBUtility
{
public class Logger
{
public Logger()
{
StreamWriter sw = null;
try
{
string d = DateTime.Now.ToString("yyyy年MM月dd日");
string path = Application.StartupPath;
if (File.Exists(path + "\\" + d + ".log"))
{
sw = new StreamWriter(path + "\\" + d + ".log");
}
else
{
sw = File.CreateText(path + "\\" + d + ".log");
}
}
catch (SqlException ex)
{
Console.WriteLine(ex.Message);
}
sw.Close();
}
public void log(String message)
{
StreamWriter sw = null;
try
{
string d = DateTime.Now.ToString("yyyy年MM月dd日 hh:mm:ss");
sw.WriteLine(d + ":" + message);
sw.Flush();
}
catch (SqlException ex)
{
Console.WriteLine(ex.Message);
}
sw.Close();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -