List Drive Names In ListBox

Posted on 2006-03-23
Medium Priority
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

DotNetLover_Baan earned 200 total points
ID: 16271865
Hi there,
check it out; http://www.vbdotnetheaven.com/UploadFile/mahesh/EnvironmentVariable04232005084223AM/EnvironmentVariable.aspx?ArticleID=b2e84a7c-4a2b-490a-a4ef-d41ad93fab6d

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


Accepted Solution

Vulten earned 1800 total points
ID: 16272503
Or just...

 ListBox1.DataSource = Environment.GetLogicalDrives()

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 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