Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can we reserve space for a file, like Explorer does before copying?

I tried to copy big file to usb-flash and broke a thread, result - 900MB file was created per few seconds, BUT process still running and its existence time is equal to time for copying file.

(Solutions excluding FileStream.Length/Seek, because it's slow on a flash drive.)
Posted
Updated 2-Apr-10 7:58am
v4

Here is an idea. Why not create the file first and then replace the bytes with the ones from your original file. Here is a link that might help. http://bytes.com/topic/c-sharp/answers/701359-how-create-new-file-fixed-size. Several methods are mentioned and one might have the properties you want.

There could be issues as it might take just as long to create an empty file as to copy one, but I think that this might be worth a shot.

Hope this helps.
Ken
 
Share this answer
 
halabella wrote:
reserve space


where? on disk? on the Explorer panel?

Explorer does not reserve any disk space, it checks sufficient disk space is available, however if that fills up due to some other activity the copy process will still fail.

:)
 
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