How to cancel (break) File.Copy?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create an appropriate file manager in my application. I want
to implement a cancelable file copy function with a Form which contains
processbar and cancel button.

Is there a way to cancel copy operation?

If I create appropriate file copy operation which is the best strategy? Copy
step by step (megabyte by megabyte) in a copy thread? Because I can break my
loop. How much should be one step: byte, megabyte, other?

Do you have any idea?

Thanks

Frankie
 
The fact that it is not straightforward on the desktop
(http://msdn.microsoft.com/msdnmag/issues/05/02/NETMatters/) makes me think
it will be at least awkward on the device.

As for the "strategy" question... In this or other scenarios where you want
to do some long processing and at the same time show progress and/or offer
cancellation, the answer is the same: only you know every how often you
should do that. What is acceptable for your users is something you can
determine and nobody else. If you don't know how long each task takes, then
measure and decide.

Since we are talking about long running tasks, cancellation and progress, I
must mention as a generic reference that may be useful to you in the future
the BackgroundWorker from SDF form OpenNETCF:
http://www.danielmoth.com/Blog/2004/12/backgroundworker-sample.html

Cheers
Daniel
 
Back
Top