Avatar of FRIBBLE1
FRIBBLE1
 asked on

Trubble with System.IO.Directory.GetLogicalDrives.GetType

I'm trying to find out what type of each drive is then remove the ones which arnt hard drives.

The GetLogicalDrives works fine but how do i then uses this incomation in the Get type method.

drives = System.IO.Directory.GetLogicalDrives
System.IO.Directory.GetLogicalDrives.GetType()

Thanks for your help
Visual Basic.NET

Avatar of undefined
Last Comment
toddhd

8/22/2022 - Mon
iboutchkine

that is how you can get the drive type

Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA"
(ByVal nDrive As String) As Int32

Dim s As String
  Dim drivers() As String = Directory.GetLogicalDrives
  For Each s In drivers
   If GetDriveType(s) = 5 Then
    Console.WriteLine("drive letter {0} is a CDROM", s)
   End If
Next
ASKER CERTIFIED SOLUTION
toddhd

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
toddhd

oops, too slow on the draw :)
FRIBBLE1

ASKER
Thanks very much
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
toddhd

FWIW, stick with iboutchkine's suggestion, or some version of that anyway. This blog (http://blogs.vbcity.com/drydo/) shows that it is faster than the one I posted :)