Restoring Disconnected Network Drive via VB.NET
Posted on 2008-10-22
I have a VB.NET (.NET Framework 2.0) program launching every minute on a Windows 2003 server and processing files from a remote server. It accesses the files via UNC (e.g, \\SERVER22\\exports\rcv or \\18.104.22.168\exports\rcv). The program launches fine for days but then gets "stuck". When I log in to the server I always find the equivalent mapped network drive to be "disconnected". Killing the app's process and executing the app manually confirms it can't access the UNC resource (it just hangs). I have to double click the mapped drive in Explorer to reconnect the drive and then launch the app. This might be acceptable if it happened once a month but the problem occurs in bunches. The last two weeks were fine but I've now had three network drive disconnections in the last 24 hours.
How can the app ensure the UNC resource is available and if it isn't, do the necessary reconnection?