Closed giovanierthal closed 2 years ago
It looks to me from you code, and the error message that the "task was canceled" because it lost contact with the destination computer you were copying to, which you would expect it to do if "Desktop-dp37hhu" is disconnected from the network as it will no longer to be able to continue the process of copying the files from source to destination.
An error being generated when destination is no longer available is not anything specific to this library, you would also get an error if you were using RoboCopy from command line to copy from "C:\Users\myuser\Downloads\movie\" to "\Desktop-dp37hhu\myfolder\" and then disconnected "Desktop-dp37hhu" part way through the copy process.
e.g.
RoboCopy"C:\Users\myuser\Downloads\movie\" "\\Desktop-dp37hhu\myfolder\" *.* /E /J /A /R:1 /W:2
Simple solution would be to ensure "Desktop-dp37hhu" is not disconnected from network when you have a copy running, or to add in some of your own code to check and make sure that "Desktop-dp37hhu" is available before starting the copy.
Checking availability of the destination during the copy process is beyond the current scope of the project and sample app because as above you would have exactly same issue if using RoboCopy via command line just as you do using it with this wrapper.
You could potentially handle the RoboCommand.OnError event (backup.OnError += copy_OnError;
) to check if destination is available, prompt if it isn't and then restart copy process when it is.
Hope this make sense
Closed as no responses
Hello.
I'm not a C# programmer. But I need to use your solution in my project.
I have the following code:
When the computer "Desktop-dp37hhu" is disconnected from the network, the following exception is raised.
Where is the problem?