Aug 3rd, 2006, 07:45 PM
#1
Thread Starter
Addicted Member
[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
Aug 3rd, 2006, 08:31 PM
#2
Re: [2005] Enumerate Hard Drive Letters?
Perhaps this is not the way you wish to do it, but its functional
VB Code:
For Each i As IO.DriveInfo In IO.DriveInfo.GetDrives
MsgBox(i.Name)
Next
Aug 3rd, 2006, 09:09 PM
#3
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...
Aug 4th, 2006, 04:09 AM
#4
Thread Starter
Addicted Member
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.
Aug 4th, 2006, 05:32 AM
#5
Thread Starter
Addicted Member
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!
Attached Files
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width