If I try to write a file to a network drive, that is disconnected, I get an error.
If I doubleclick the drive in explorer, the network drive is reconnected.
Using System.Io.Driveinfo.IsReady I can check if a drive is ready - but how can I reconnect it in code?
Step 1: Press the Windows + R keys and type regedit in the Run dialog box. Step 2: Locate the following key and click on it. Step 3: On the right-hand pane, double-click on Restore Connection and set the value at 0. Click OK to save the changes.
If you disconnect a mapped network drive or delete a network location, but it doesn't disappear from File Explorer, the reason might be that File Explorer didn't get to refresh its contents. Try pressing the F5 key on your keyboard or click/tap on Refresh in the right-click menu inside File Explorer.
This behavior occurs because the systems can drop idle connections after a specified time-out period (by default, 15 minutes) to prevent wasting server resources on unused sessions. The connection can be re-established quickly, if necessary.
Would this code which shows how to map the drive and unmap it dynamically at runtime do? This is on CodeGuru.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With