这个方法有问题
WriteTextAsync(string text, string path)
每次(foreach时)都打开(using),再释放文件,很慢,考虑只调用一次即可。创建一次,然后其它的方法只写入行,最后释放。
public void WriteTextAsync(string text, string path)
{
using (StreamWriter outputFile = new StreamWriter(path, true))
{
outputFile.WriteLineAsync(text);
}
}
修改为
string path="";
StreamWriter writer= new StreamWriter(path, true);
public void WriteTextAsync(StreamWriter writer,string text)
{
writer.WriteLineAsync(text);
}
每次调用时,将创建好的对象传入,等这些字符串都写入完成后,再释放writer对象.
WriteTextAsync(writer,c);
专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms