Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I was not sure which forum to put this. I use VB.net so i posted here.

I have a lot of data that i am creating via VB.net and then i have to write all that data to a txt file. I have an option to write to several files (500-1000 files), or i can write to a single file. My question is which way would be the fastest way (time to write to hard drive)?

Just in case additional info in needed for the answer. Each file will have about 20-40 lines of data. Each line will have about 20-30 characters.

Thank you in advance,

-J
Posted
Comments
PIEBALDconsult 29-Oct-13 0:39am    
I assume it would take just as long unless you used a number of threads, and even that would likely make no difference.
If there is no other reason to consider multiple files, I'd stick with one.
On the other hand, reading the data may be a factor in how you write.

1 solution

It really depends on many factors, your content and its processing, so it's hard to give one single recipe. Generally speaking, writing in big chunks is better, but the effect of it is not so straightforward, because of file stream buffering. You calculations can also become a bottleneck. I would just gain some practice by timing different scenarios, then you can quickly develop the sense of it. Only one recipe is universal: avoid doing something stupid. :-)

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900