[RESOLVED] [2005] Enumerate Hard Drive Letters?
Hi Guys,
I was wondering how you could list all the hard drive letters of a system. So I could have them as C, D, E, F, G and H etc to use in a String array.
I did some home work and found you can use ManagementClass("Win32_LogicalDisk")? I would love to see an example if that's possible. :)
Thanks in advance,
McoreD
Re: [2005] Enumerate Hard Drive Letters?
Perhaps this is not the way you wish to do it, but its functional :afrog:
VB Code:
For Each i As IO.DriveInfo In IO.DriveInfo.GetDrives
MsgBox(i.Name)
Next
Re: [2005] Enumerate Hard Drive Letters?
If you care to use WMI, which should really only be used to get extra hardware info about the drives, as the letters can be found using regular code, then check out my codebank submission in my sig... just change it to use the WMI class you desire...
Re: [2005] Enumerate Hard Drive Letters?
Thanks Atheist! That's exactly what I needed.
VB Code:
For Each i As System.IO.DriveInfo In IO.DriveInfo.GetDrives
If i.DriveType = IO.DriveType.Fixed Then
Console.WriteLine(i.Name)
End If
Next
gigemboy, thanks I will check out WMI in your sig.
1 Attachment(s)
Re: [RESOLVED] [2005] Enumerate Hard Drive Letters?
This is the small fruit of the attempt. :)
Always wanted an easy way to defrag the hard drives one after the other, using Windows Defragmenter.
Thanks guys!