给你一个概念性的例子
[C#] 纯文本查看 复制代码 List<string> strlist = new List<string>();
/// <summary>
/// 写入文件
/// </summary>
/// <param name="msg">要写入的内容</param>
/// <returns>0成功,其他为操作失败</returns>
public int Writer(string msg)
{
strlist.Add(msg);
//超过10000行再写入
if (strlist.Count > 10000)
{
using (StreamWriter sr = new StreamWriter("path"))
{
//处理写入 strlist
}
}
return 1;
}
/// <summary>
/// 写入文件
/// </summary>
public void LastWriter(string msg)
{
using (StreamWriter sr = new StreamWriter("path"))
{
//处理写入 strlist
}
}
|