List Drive Names In ListBox

Posted on 2006-03-23
Last Modified: 2007-12-19

Anyone know how to list in a listbox all the drives on your computer?

I want the list to show the drive names, so if I change the name of my main hard drive to MyHardDrive which originally was Local Drive, in the listbox it should show MyHardDrive ...

Please help
Question by:narmi2
    LVL 18

    Assisted Solution

    Hi there,
    check it out;

    This is what you can use:
    ' Get all logical hard drives
    Dim drives As String()
    Dim counter As Int32
    drives = Environment.GetLogicalDrives()
    Console.WriteLine("Available drives:")
    For counter = 0 To drives.Length - 1

    LVL 4

    Accepted Solution

    Or just...

     ListBox1.DataSource = Environment.GetLogicalDrives()

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now