Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

GetDirectories for Empty Drive

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
G Dean Blake - 28 Apr 2005 01:24 GMT
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
Herfried K. Wagner [MVP] - 28 Apr 2005 11:16 GMT
"G Dean Blake" <gb@nospam.com> schrieb:
> For Each myFolder in Folder.GetDirectories...
>
[quoted text clipped - 6 lines]
> How can I test for this without getting an exception and all of those
> dialog boxes?

Untested:

<URL:http://www.google.de/groups?selm=%23lgX6tpBEHA.3804%40TK2MSFTNGP09.phx.gbl>

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

G Dean Blake - 29 Apr 2005 01:12 GMT
That gets rid of the error dialogs but I still get an exception.
Thanks,
G
> "G Dean Blake" <gb@nospam.com> schrieb:
>> For Each myFolder in Folder.GetDirectories...
[quoted text clipped - 11 lines]
>
> <URL:http://www.google.de/groups?selm=%23lgX6tpBEHA.3804%40TK2MSFTNGP09.phx.gbl>
Herfried K. Wagner [MVP] - 29 Apr 2005 23:08 GMT
"G Dean Blake" <gb@nospam.com> schrieb:
> 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.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.