Trouble With Directory.GetDirectories and Disconnected Network Dri

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I get a list of drives using the Directory.GetLogicalDrives(), it gives
me all drives including disconnected network drives. When I attempt to use
Directory.GetDirectories() on a disconnected drive, the GetDirectories Method
stops responding. I also tried to use properties such as
DirectoryInfo.Attributes but I have the same problem. How do I detect if one
of the logical drives in my list is a disconnected network drive? I want to
be able to detect this before I attempt to read it.

Thanks
 
When I get a list of drives using the Directory.GetLogicalDrives(), it gives
me all drives including disconnected network drives. When I attempt to use
Directory.GetDirectories() on a disconnected drive, the GetDirectories Method
stops responding. I also tried to use properties such as
DirectoryInfo.Attributes but I have the same problem. How do I detect if one
of the logical drives in my list is a disconnected network drive? I want to
be able to detect this before I attempt to read it.

Thanks

Try using the DriveInfo object. To get a list of all the drives use this:

DriveInfo[] allDrives = DriveInfo.GetDrives();

The DriveInfo object has a method IsReady() to let you know if the drive
can be accessed
 
I tried the DriveInfo.IsReady() method just as you suggested and the same
problem occurs.

The IsReady() method stops responding when encountering a disconnected
network drive.

The DriveInfo.GetDrives() method still lists the disconnected drives.

I'm assuming that there is a registry entry that I can look for, since
Windows is able to post the "Disconnected Network Drive" status. I just
don't know where that would be.

Thanks

Rad said:
When I get a list of drives using the Directory.GetLogicalDrives(), it gives
me all drives including disconnected network drives. When I attempt to use
Directory.GetDirectories() on a disconnected drive, the GetDirectories Method
stops responding. I also tried to use properties such as
DirectoryInfo.Attributes but I have the same problem. How do I detect if one
of the logical drives in my list is a disconnected network drive? I want to
be able to detect this before I attempt to read it.

Thanks

Try using the DriveInfo object. To get a list of all the drives use this:

DriveInfo[] allDrives = DriveInfo.GetDrives();

The DriveInfo object has a method IsReady() to let you know if the drive
can be accessed
 
Back
Top