问题描述
我需要写值,大多数情况下是将其加倍到VB.NET的文本文件中.我从VB6移植了代码,但是VB.NET中的VB6 write#fileID,vars)的性能非常差,它引入了大约一小时的延迟.
我已经尝试了streamwrite及其表现不错;
我正在为streamwriter使用write(string)方法,并使用变量名称来连接值,如下所示:streamwriter.write(var1&, & var2&","..."和"...".
此版本的写作使我能够拥有每个语句在文件中写入多个变量.
我的问题是文件的内容不正确,这与VB.NET中缓慢的VB6写入产生的变量不同.
是否有更好的方法来满足此要求;最好使用流写器?我不能使用streamwriter.write(double),因为我必须使用多行代码,因为我在收敛性测试循环中写了大约800个var,导致总共进行了200万次写操作.
谢谢您的任何帮助,
Mugu.
Hi,
I need to write values, mostly doubles into a text file in VB.NET. I ported the code from VB6, but the performance of the VB6 write#fileID, vars) in VB.NET, is very bad, it introduces a delay of about one hour.
I have tried out the streamwrite, and its performance is good; it's actually faster than VB6 write.
I am using the write(string) method for the streamwriter, and I am concatenating the values using variable names as follows: streamwriter.write(var1 &","& var2 &","&....&","& var n &",").
This version of write enables me to have more than one variable written to file per statement.
The problem that I have is that the content of the file is incorrect, unlike the one produced by the slow VB6 write in VB.NET.
Is there a better way of achieving this requirement; preferably using the streamwriter? I cannot use the streamwriter.write(double), becuase I'll have to use multiple lines as I am writing about 800 vars in convergence test loops resulting in a total of just over 2 million writes.
Thank you for any help,
Mugu.
推荐答案
这篇关于在VB.NET中写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!