James Rose Posted October 23, 2009 Share Posted October 23, 2009 I'm curious if anyone has dealt with the issue of a network connection dropping during the file process and what they did to have the copy continue or restart? I'm using VB.NET 2008 and the "File.Copy(CurrentLocation, NewLocation, True)" function. Thanks for any thoughts. James Link to comment Share on other sites More sharing options...
0 Rohdekill Posted October 24, 2009 Share Posted October 24, 2009 check file size of destination and compare it to original. Then do it again. If it increases in size, the copying is still ongoing. If it's the same size the second time and equal to original, it's good, else it failed. Link to comment Share on other sites More sharing options...
0 James Rose Posted October 27, 2009 Author Share Posted October 27, 2009 Thanks, but that's not specifically what I meant. I mean is there a specific exception that can be handled (yes I can pull my network plug, and I will) or process that I should be aware of. Some of this data is quite large and if the network drops 95% of the way through it would be bad to have to start over. Thanks for the response. Link to comment Share on other sites More sharing options...
0 Eric Veteran Posted October 27, 2009 Veteran Share Posted October 27, 2009 You could try catching SocketException and check the SocketErrorCode property in the catch{} block. I'm not 100% sure which error it would throw, but I'm assuming a ConnectionReset or ConnectionAborted. (Try it and unplug the connection to see what error is thrown.) Link to comment Share on other sites More sharing options...
Question
James Rose
I'm curious if anyone has dealt with the issue of a network connection dropping during the file process and what they did to have the copy continue or restart?
I'm using VB.NET 2008 and the "File.Copy(CurrentLocation, NewLocation, True)" function.
Thanks for any thoughts.
James
Link to comment
Share on other sites
3 answers to this question
Recommended Posts