agamemnon12
Cloud Innovator
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
400 XP
This tutorial that I’m going to teach you is about how to display all drives into the listview using Vb.Net. This method is useful when you have to display the computer drives in the listview. With this, you will be able to see and have an idea what drives are available on your computer. Simply follow the instructions below and you will be done in no time.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application.
Step 2
Do the Form just like shown below.
Step 3
Go to the code view, create a sub procedure for retrieving all drives.
Step 4
Double click the button and call the method that you have created to execute when the button is clicked.
For more question about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
FB Account – https://www.facebook.com/onnaj.soicalap
Or feel free to comment below.
Creating Application
Step 1
Open Microsoft Visual Studio 2015 and create a new windows form application.

Step 2
Do the Form just like shown below.

Step 3
Go to the code view, create a sub procedure for retrieving all drives.
- Private
Sub
retrieveDrives()
- ListView1.Items.Clear()
- Dim
inc As
Integer
= 0
- For
Each
drive As
IO.DriveInfo In
IO.DriveInfo.GetDrives
- Dim
drivename As
String
= drive.Name
- Dim
driveType As
String
= ""
- Dim
driveltr As
String
= drive.Name
- If
drive.IsReady AndAlso drive.VolumeLabel <> ""
Then
- drivename = drive.VolumeLabel
- Else
- Select
Case
drive.DriveType
- Case
IO.DriveType.Fixed : drivename = "Local Disk"
- Case
IO.DriveType.CDRom : drivename = "CD-ROM"
- Case
IO.DriveType.Network : drivename = "Network Drive"
- Case
IO.DriveType.Removable : drivename = "Removable Disk"
- End
Select
- End
If
- Select
Case
drive.DriveType
- Case
IO.DriveType.Fixed : driveType = "Local Disk"
- Case
IO.DriveType.CDRom : driveType = "CD-ROM"
- Case
IO.DriveType.Network : driveType = "Network Drive"
- Case
IO.DriveType.Removable : driveType = "Removable Disk"
- End
Select
- ListView1.Items.Add(drivename)
- ListView1.Items(inc).SubItems.Add(driveltr)
- ListView1.Items(inc).SubItems.Add(driveType)
- inc += 1
- Next
- End
Sub
Step 4
Double click the button and call the method that you have created to execute when the button is clicked.
- Private
Sub
Button1_Click(sender As
Object
, e As
EventArgs) Handles Button1.Click
- retrieveDrives()
- End
Sub
For more question about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
FB Account – https://www.facebook.com/onnaj.soicalap
Or feel free to comment below.