• 0

[VB.NET] File Copy + connection drop


Question

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

  • 0

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

  • 0

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.