/// <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;
}
}
本文介绍了一个用于将信息写入记事本的简单函数,包括如何使用DateTime.now()获取当前时间,并将其与文本信息一起写入指定路径。
1万+

被折叠的 条评论
为什么被折叠?



