Direcory Exists?

E

elziko

I want to use the Directory.Exists method to see if a directory exists. But
it doesn't seem to work for the root of a removable (USB) drive.

I plug in my drive and it gets allocated a letter ("F:"). I then confirm
that I can view the drive in Windows Explorer but:

Directory.Exists("F:\")

returns False!

Directory.Exists("C:\")

returns True as expected!

Is this by design or a bug? Is there an alternative that will work for all
paths including on removable drives?

TIA
 
A

AMDRIT

I was not able to reproduce your results. I have tried several USB drives
and they all came back as expected. I wonder if your USB device is
encrypted?

If I were to do this in VB 6, I would have used either API or FSO using
samples from Randy Birch's website vbnet.mvps.org, and it occured to me that
I didn't know how to enumerate drives in .Net. You would think that
System.IO would allow you this information, but nay. I found an article
http://www.codeproject.com/csharp/logicaldiskinfo.asp that shows
System.Management is the namespace that you would use. It appears that it
is just a WMI wrapper with late bound objects and structures.
 

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