I have a file that's about 7 MB that saves to my local share in a matter of seconds. However, saving that file to a network location takes minutes. I'm wondering what I can do to speed this up. Here are my current options:
- Save the data to a temporary file on the local machine, then copy the temporary file over to the network path. I'll probably do this as this is the easiest and the most bang for the buck.
- Use
SetFilePointerEx()
andSetEndOfFile()
. I thought this might be useful based on the answer to this question: http://stackoverflow.com/questions/455297/creating-big-file-on-windows - Buffer writes. I could cache write data myself and flush when the buffer full, but wouldn't this be redundant with the caching that is already done by the OS?
#1 seems like the best option, but I'm wondering if anyone has any advice on a better way to speed up saving to network paths?
Edit: The network is on a gigabit LAN, so speed shouldn't be an issue. Copying the file to the network path takes about 1 second. I just noticed we're calling WriteFile() on smaller chunks of data then we probably should, so optimizing the higher level code to write bigger chunks will probably help, but the speed difference is still so significant that it's still a worthwhile question to ask.