/// <summary>
/// 将数据写入txt
/// </summary>
/// <param name="str"></param>
public void LogWriteTxt(string str)
{
string path = Application.StartupPath +"\\"+"result_number.txt";
str = DateTime.Now.ToString("yyyy-MM-dd") +str;
if (!File.Exists(path))
{
FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(str);
sw.Flush();
sw.Close();
}
else
{
FileStream fs = new FileStream(path, FileMode.Append);
//文本写入
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(str);
sw.Flush();
sw.Close();
}
}
C#——将数据写入txt
猜你喜欢
转载自blog.csdn.net/qq_20799821/article/details/108520168
今日推荐
周排行