Q : Comment lister les disques accessibles et l'espace disponible
R : Par l'utilisation de filesystem Object
Rajouter la référence à Microsoft Scripting Runtime, ou supprimer les types de variables..
le résultat est affiché dans la fenêtre exécution de l'éditeur VB ( CTRL-G)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 ' ' Rajouter la référence à ' Microsoft Scripting Runtime ' Sub InfoEspaceDisques() Dim fso As New FileSystemObject, d As Drive, txt As String For Each d In fso.Drives 'If d.DriveType = 2 Or d.DriveType = 5 or d.DriveType = 3 Then If d.DriveType = Fixed Or d.DriveType = RamDisk Or _ d.DriveType = Remote Then txt = txt & "Disk " & d.DriveLetter & "(" & d.VolumeName & ")" & vbTab txt = txt & "Total : " & d.TotalSize & vbTab txt = txt & "Libre : " & d.FreeSpace & vbCrLf Debug.Print txt End If Next Set fso = Nothing End Sub
PS: la discussion initiale : Espace disque , merci au participant à cette discussion
Partager