GetDirectories for Empty Drive

G

G Dean Blake

I have a directoryInfo named Folder with a name property of "A:\". I'm then
trying to loop through and expand it a level.

But when I say:
For Each myFolder in Folder.GetDirectories...

A series of dialog boxes are displayed saying the drive is empty (it is) and
an exception is thrown "drive is empty". The dialog boxes appear before I
get control in the catch Statement.

This happens for empty CD drivs too.

How can I test for this without getting an exception and all of those dialog
boxes?
Thanks,
Gary
 
H

Herfried K. Wagner [MVP]

G Dean Blake said:
For Each myFolder in Folder.GetDirectories...

A series of dialog boxes are displayed saying the drive is empty (it is)
and an exception is thrown "drive is empty". The dialog boxes appear
before I get control in the catch Statement.

This happens for empty CD drivs too.

How can I test for this without getting an exception and all of those
dialog boxes?

Untested:

<URL:http://www.google.de/groups?selm=#[email protected]>
 
H

Herfried K. Wagner [MVP]

G Dean Blake said:
That gets rid of the error dialogs but I still get an exception.

You may want to put the line in a 'Try...Catch' block.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top