Connecting Tech Pros Worldwide Forums | Help | Site Map

Trouble With Directory.GetDirectories and Disconnected Network Dri

=?Utf-8?B?ZGdjb29wZXI=?=
Guest
 
Posts: n/a
#1: Apr 3 '07
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

Rad [Visual C# MVP]
Guest
 
Posts: n/a
#2: Apr 3 '07

re: Trouble With Directory.GetDirectories and Disconnected Network Dri


On Mon, 2 Apr 2007 19:18:03 -0700, dgcooper wrote:
Quote:
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
--
Bits.Bytes
http://bytes.thinkersroom.com
=?Utf-8?B?ZGdjb29wZXI=?=
Guest
 
Posts: n/a
#3: Apr 4 '07

re: Trouble With Directory.GetDirectories and Disconnected Network Dri


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 [Visual C# MVP]" wrote:
Quote:
On Mon, 2 Apr 2007 19:18:03 -0700, dgcooper wrote:
>
Quote:
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
--
Bits.Bytes
http://bytes.thinkersroom.com
>
Closed Thread