Visual Basic File Copy Procedure Freezes when Network Goes Down
Posted on 2004-08-12
I have the need (let's just assume my reasoning is sound on why I want this the way I am proposing, so please no comments like "why not buy such and such a program") to copy files across a VPN from 1 server to another and I want to do this with a Visual Basic App.
I want this app to be fail safe, meaning if the VPN goes down and the program is in the middle of transferring files I want the program to timeout for a specfic amount of time and retry that file a set amount of times before it gives up and goes on to the next.
I have tried numerous methods to test whether the network is up before attempting the Copy, such as FSO.isready function. FSO.FileExists function, Using semi-asycrounyous API Call to "CopyFileEx Lib". To test the program I start the copying procedure and midway through the list I'll will disable my network connection. Everyway I do it without fail the VB App freezes and cannot continue on.
One thought I had was writing a second app to do the actual coping, that way if it froze the main app could detect this close it and try again a certain amount of time later. This 2nd helper app could check in each after completing each file or even be restarted for each file.
Is this last method viable before I waste my time tryign to configure it?
Do I need to find a completely Asyncrounous way of doing this so as to not freeze the main app?
Anybody have any thoughts on how to accomplish this in a way I have not thought about?
Any help is greatly appreciated from a point in the write direction to snipit's of code.
Thanks a million