Langkah pertama , siapkan 1 buah button dan 1 buah listbox dalam form project
dibagian general tuliskan "Imports System.IO" (tanpa tanda petik)
double click pada button1 , lalu copy kode di bawah ini ..
Dim allDrives() As IO.DriveInfo = IO.DriveInfo.GetDrives()
Dim d As IO.DriveInfo
For Each d In allDrives
If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then
ListBox1.Items.Add(d.VolumeLabel).ToString()
Else
If d.IsReady = True And Not d.DriveType = DriveType.Removable Then
ListBox1.Items.Add(d.RootDirectory).ToString()
End If
End If
Next
Dim d As IO.DriveInfo
For Each d In allDrives
If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then
ListBox1.Items.Add(d.VolumeLabel).ToString()
Else
If d.IsReady = True And Not d.DriveType = DriveType.Removable Then
ListBox1.Items.Add(d.RootDirectory).ToString()
End If
End If
Next
Selamat mencoba
Tidak ada komentar:
Posting Komentar