0

I am using FileInfo method CopyTo to copy some large files. I am using BackgroundWorker to do this in a separate thread.

The problem is that I would like to update a progress bar, but I can only update that between each file copy which is not often enough. There is also a similar problem with CancellationPending (and I don't know how to cancel the ongoing CopyTo without killing the thread).

What is the best option here? The most obvious is to copy the files in smaller chunks instead of using CopyTo. That would be ok, but I don't want to lose any performance (e.g. dma not being used efficiently).

1
Contributor
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Bigfoot73
0

One more thing:

The files will usually be on separate disks. So if I copy it chunk by chunk it is probably not a good idea to read-write-read-write etc. because that means only one of the disks would perform something useful at any time. Instead I would need a read thread and a write thread that needs to share a buffer and wait for each other when the buffer becomes full or empty. Not extremely hard, but not what I planned to use my time for...

What functions should I use to read and write chunks? FileStream Read and Write takes an int as offset, so I don't expect them to work for files larger than 2 GB. (Not an issue in this case since the files are 1 GB, but I would like to make it right from the start.)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.