Testing for empty drives

  • Thread starter Thread starter G Dean Blake
  • Start date Start date
G

G Dean Blake

dim DriveList as string() = Environment.GetLogicalDrives
gives me a string array of every drive on the system

If I cast any of those strings as a directoryinfo, and it is, for instance,
'A:\' and drive A is empty, I get an exception when it is referenced.

Is there any way to test to see if it will cause an exception before getting
the exception?
Thanks,
G
 
G Dean Blake said:
dim DriveList as string() = Environment.GetLogicalDrives
gives me a string array of every drive on the system

If I cast any of those strings as a directoryinfo, and it is, for
instance, 'A:\' and drive A is empty, I get an exception when it is
referenced.

Is there any way to test to see if it will cause an exception before
getting the exception?

You can try to catch the exception.
 
Back
Top