信息写入记事本方法

/// <summary>
/// 信息写入记事本
/// </summary>
/// <param name="text"></param>
/// <param name="path"></param>
public static void Write(string text, string path)
{
try
{
DateTime newDate = DateTime.Now;
string msg = newDate.ToLongTimeString() + ":" + text;
StreamWriter sw = File.AppendText(path);
sw.WriteLine(msg);
sw.Flush();
sw.Close();

}
catch (Exception ex)
{
throw ex;
}
}

posted @ 2014-05-15 13:35  ChineseMoonGod  阅读(245)  评论(0编辑  收藏  举报