Directory.GetDirectories method and IOException

  • Thread starter Thread starter Carl Rapson
  • Start date Start date
C

Carl Rapson

I have some code that is checking a directory for subdirectories, using the
Directory.GetDirectories method (I got this code from a sample app):

Dim directories as String()
Try
directories = Directory.GetDirectories(path)
Catch ex as System.IO.IOException
End Try

When path is set to "A:\" (the floppy drive), and there is no disk in the
drive, I am getting the following error message box: "There is no disk in
the drive. Please insert a disk into drive A:." As far as I can tell, this
is the "drive not ready" error, which I thought should be handled by
catching IOException. I only get this error for the floppy (A:) drive; I
don't get this error for my CD-ROM drive, even though there's no disk in the
CD drive. Furthermore, I only get this message when I am running outside of
Debug mode; in Debug mode, I don't see this error message. If I remove the
catch for IOException, I see a message saying "The device is not ready" in
both modes, but I still only see the first message when in non-Debug mode.

Why isn't this error being caught by IOException? How can I avoid this
message when there is no disk in drive A:?

Thanks for any information,

Carl Rapson
 

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

Back
Top