Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Enumerate Hard Drive Letters?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252

    Resolved [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

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] Enumerate Hard Drive Letters?

    Perhaps this is not the way you wish to do it, but its functional

    VB Code:
    1. For Each i As IO.DriveInfo In IO.DriveInfo.GetDrives
    2.             MsgBox(i.Name)
    3.         Next
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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...

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252

    Re: [2005] Enumerate Hard Drive Letters?

    Thanks Atheist! That's exactly what I needed.

    VB Code:
    1. For Each i As System.IO.DriveInfo In IO.DriveInfo.GetDrives
    2.             If i.DriveType = IO.DriveType.Fixed Then
    3.                 Console.WriteLine(i.Name)
    4.             End If
    5.         Next

    gigemboy, thanks I will check out WMI in your sig.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252

    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 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
  •  



Click Here to Expand Forum to Full Width