Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reconnecting a disconnected network drive

Tags:

c#

.net

windows

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?

like image 821
Kjensen Avatar asked Nov 27 '09 11:11

Kjensen


People also ask

How do I reconnect a disconnected drive in Windows 10?

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.

What happens if I disconnect a network drive?

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.

Why does it say disconnected network drive?

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.


1 Answers

Would this code which shows how to map the drive and unmap it dynamically at runtime do? This is on CodeGuru.

like image 84
t0mm13b Avatar answered Oct 25 '22 11:10

t0mm13b