Je me demande a qui y sert le code que t'a trouvé ? Surtout le InfosLecteurs
Enfon bon, AvailableFreeSpace retourne se que tu veux non ?
For Each Drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives()
If Drive.IsReady Then
System.Windows.Forms.MessageBox.Show(Drive.AvailableFreeSpace.ToString())
End If
Next,
On Error Resume Next
Dim NombreLecteurs As Byte = My.Computer.FileSystem.Drives.Count
Dim NomsLecteurs As System.Collections.ObjectModel.ReadOnlyCollection(Of System.IO.DriveInfo)
Dim InfosLecteurs(NombreLecteurs, 8) As String
Dim Compteur As Byte = 1
'on commence les lignes du tableau à 1
NomsLecteurs = My.Computer.FileSystem.Drives
For Each info As System.IO.DriveInfo In NomsLecteurs
Super merci bien.
J'ai modifié ton code et c'est pile ce que je voulais.
For Each Drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives()
If Drive.IsReady Then
Dim f As String
f = Drive.AvailableFreeSpace
Dim j As String
j = f / 1000000000
System.Windows.Forms.MessageBox.Show("Vous disposez de: " + j + " Go sur " + Drive.Name)
End If
Next
Oulà ...
Pourquoi faire une division avec des chaine de caractères ? C'est à l'affichage qu'il faut transformer en chaîne.
Et pour concatiser des chaine on utilise l'operateur &
Et 1Go n'est pas égale à 1000000000 octets.
Pour du dotnet powwaaaa ca donnerai :
Dim FreeSpace As Double = System.Math.Round(Drive.AvailableFreeSpace / 1024 / 1024 / 1024, 1)
'Dim FreeSpace As Integer = System.Convert.ToInt32(Drive.AvailableFreeSpace / 1024 / 1024 / 1024)
System.Windows.Forms.MessageBox.Show(String.Format("Vous disposez de: {0} Go sur {1}", FreeSpace, Drive.Name))