File Attributes
These functions return information about all disk drives which could be used by the host computer. Some drives may be installed but are unavailable
at the moment e.g. A CD drive will not work unless there is a CD in the drive. Whilst all the drives can be identified, VB.Net cannot retrieve
certain details (e.g. disk capacity) from drives that are not currently working.
Private Function ListDiskDrives() As List(Of Char)
Dim ret As New List(Of Char)
For Each d As IO.DriveInfo In IO.DriveInfo.GetDrives
ret.Add(CChar(Mid(d.Name, 1, 1)))
Next
Return ret
End Function
'
Private Function IsDriveReadyToUse(driveletter As Char) As Boolean
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
Return d.IsReady
End Function
'
Private Function GetDriveType(driveletter As Char) As String
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
Return d.DriveType.ToString
End Function
'
Private Function GetDriveRootDirectory(driveletter As Char) As String
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
Return d.RootDirectory.ToString
End Function
'
Private Function GetDriveAvailableFreeSpace(driveletter As Char) As Long
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
If Not d.IsReady Then Return 0
Return d.AvailableFreeSpace
End Function
'
Private Function GetDriveTotalFreeSpace(driveletter As Char) As Long
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
If Not d.IsReady Then Return 0
Return d.TotalFreeSpace
End Function
'
Private Function GetDriveTotalSize(driveletter As Char) As Long
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
If Not d.IsReady Then Return 0
Return d.TotalSize
End Function
'
Private Function GetDriveFormat(driveletter As Char) As String
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
If Not d.IsReady Then Return 0
Return d.DriveFormat
End Function
'
Private Function GetDriveVolumeLabel(driveletter As Char) As String
Dim d As DriveInfo = New DriveInfo(driveletter & ":\")
If Not d.IsReady Then Return 0
Return d.VolumeLabel
End Function
DigitalDan.co.uk