Pause, Resume Copy of file... How (C#)?
-
Hi I have been using Total Copy for like for ever, but I always wanted to write my own App for copying files with the same functionality. How can I pause and resume the copy of a file in C# (WinForms) as Total Copy does? I've tried Googling, but I'm not finding what I'm looking for. Thanks in advance. :)
-
Hi I have been using Total Copy for like for ever, but I always wanted to write my own App for copying files with the same functionality. How can I pause and resume the copy of a file in C# (WinForms) as Total Copy does? I've tried Googling, but I'm not finding what I'm looking for. Thanks in advance. :)
Use FileStream to copy the source file into the target file. When you want to pause the opration you just need to close the stream. When you want to resume, you can use seek method find last written byte and restart writing. Another way could be to have copy operation on a separate thread which can be stopped and resumed when required. I have not tried this hence not sure. Hope this helps.
Happy Holi[^] जय हिंद
-
Use FileStream to copy the source file into the target file. When you want to pause the opration you just need to close the stream. When you want to resume, you can use seek method find last written byte and restart writing. Another way could be to have copy operation on a separate thread which can be stopped and resumed when required. I have not tried this hence not sure. Hope this helps.
Happy Holi[^] जय हिंद