1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Public Class Form1
Private volume As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
ListView1.Items.Clear()
For Each Drive In My.Computer.FileSystem.Drives
Dim DriveInfo As String = Drive.Name
If Drive.DriveType = DriveType.Removable Then
volume = ShowTotalFileSize(Drive.TotalSize)
ListView1.LargeImageList = ImageList1
Dim lv As New ListViewItem
lv = ListView1.Items.Add("USB", 0)
lv.SubItems.Add(DriveInfo)
lv.SubItems.Add(volume)
Dim folders() As String = Directory.GetDirectories(Drive.Name, "*.*", SearchOption.AllDirectories)....rechercher des dossiers dans votre clé usb
For Each folder As String In folders
ComboBox1.Items.Add(folder)
ComboBox1.SelectedIndex = 0
Next
Dim fichiers() As String = Directory.GetFiles(Drive.Name, "*.docx", SearchOption.AllDirectories).....rechercher des fichiers dans votre clé usb.
For Each fichier As String In fichiers
ComboBox2.Items.Add(fichier)
ComboBox2.SelectedIndex = 0
Next
End If
Next
If ListView1.Items.Count > 0 Then
Label2.ForeColor = Color.Green
Label2.Text = "Connecter"
Else
Label2.ForeColor = Color.Red
Label2.Text = "No Connecter"
End If
ToolStripStatusLabel1.Text = ListView1.Items.Count.ToString & " USB Trouvés ...."
End Sub
Function ShowTotalFileSize(ByVal bytes As Long) As String
Dim stringToReturn As String = ""
If bytes < 1024 Then
stringToReturn = Format(bytes, "#,##0.0") & " octet"
ElseIf bytes < (1024 * 1024) Then
stringToReturn = Format((bytes / 1024), "#,###") & " KB"
ElseIf bytes >= (1024 * 1024) And bytes < (1024 * 1024 * 1024) Then
stringToReturn = Format((bytes / (1024 * 1024)), "#,###.0") & " MB"
ElseIf bytes >= (1024 * 1024 * 1024) Then
stringToReturn = Format((bytes / (1024 * 1024 * 1024)), "#,###.00") & " Go"
End If
Return stringToReturn
End Function |
Partager