[271] | 1 | Namespace System
|
---|
| 2 | Namespace IO
|
---|
| 3 |
|
---|
| 4 |
|
---|
[64] | 5 | Enum DriveType
|
---|
| 6 | Unknown = 0
|
---|
| 7 | NoRootDirectory
|
---|
| 8 | Removable
|
---|
| 9 | Fixed
|
---|
| 10 | CDRom
|
---|
| 11 | Network
|
---|
| 12 | Ram
|
---|
| 13 | End Enum
|
---|
| 14 |
|
---|
| 15 | Class DriveInfo
|
---|
| 16 | m_DriveName As String
|
---|
| 17 | Public
|
---|
| 18 | Sub DriveInfo(driveName As String)
|
---|
| 19 | If driveName.Length <> 1 Then
|
---|
| 20 | 'ArgumentException
|
---|
| 21 | debug
|
---|
| 22 | End If
|
---|
| 23 | driveName.ToUpper()
|
---|
| 24 | m_DriveName = driveName + ":\"
|
---|
| 25 | End Sub
|
---|
| 26 |
|
---|
| 27 | Sub ~DriveInfo()
|
---|
| 28 | End Sub
|
---|
| 29 |
|
---|
| 30 | 'property
|
---|
| 31 | Function AvailableFreeSpace() As QWord
|
---|
| 32 | Dim availableFreeSpace As ULARGE_INTEGER
|
---|
| 33 | If GetDiskFreeSpaceEx(m_DriveName, availableFreeSpace, ByVal 0, ByVal 0) Then
|
---|
| 34 | Return (availableFreeSpace.HighPart << 32) Or availableFreeSpace.LowPart
|
---|
| 35 | Else
|
---|
| 36 | 'IOException
|
---|
| 37 | End If
|
---|
| 38 | End Function
|
---|
| 39 |
|
---|
| 40 | Function DriveFormat() As String
|
---|
[142] | 41 | Dim systemName[15] As TCHAR
|
---|
| 42 | If GetVolumeInformation(m_DriveName, NULL, NULL, NULL, NULL, NULL, systemName, Len (systemName)) Then
|
---|
[64] | 43 | Return systemName
|
---|
| 44 | Else
|
---|
| 45 | 'IOException
|
---|
| 46 | End If
|
---|
| 47 | End Function
|
---|
| 48 |
|
---|
| 49 | Function DriveType() As Long
|
---|
| 50 | Return GetDriveType(m_DriveName)
|
---|
| 51 | End Function
|
---|
| 52 |
|
---|
[142] | 53 | Function IsReady() As Boolean
|
---|
[64] | 54 | If GetVolumeInformation(m_DriveName, NULL, NULL, NULL, NULL, NULL, NULL, NULL) Then
|
---|
[142] | 55 | Return True
|
---|
[64] | 56 | Else
|
---|
[142] | 57 | Return False
|
---|
[64] | 58 | End If
|
---|
| 59 | End Function
|
---|
| 60 |
|
---|
| 61 | Function Name() As String
|
---|
| 62 | Return m_DriveName
|
---|
| 63 | End Function
|
---|
| 64 |
|
---|
| 65 | /* Function RootDirectory() As DirectoryInfo
|
---|
| 66 | End Function*/
|
---|
| 67 |
|
---|
| 68 | Function TotalFreeSpace() As QWord
|
---|
| 69 | Dim totalFreeSpace As ULARGE_INTEGER
|
---|
| 70 | If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, ByVal 0, totalFreeSpace) Then
|
---|
| 71 | Return (totalFreeSpace.HighPart << 32) Or totalFreeSpace.LowPart
|
---|
| 72 | Else
|
---|
| 73 | 'IOException
|
---|
| 74 | End If
|
---|
| 75 | End Function
|
---|
| 76 |
|
---|
| 77 | Function TotalSize() As QWord
|
---|
| 78 | Dim totalSize As ULARGE_INTEGER
|
---|
| 79 | If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, totalSize, ByVal 0) Then
|
---|
| 80 | Return (totalSize.HighPart << 32) Or totalSize.LowPart
|
---|
| 81 | Else
|
---|
| 82 | 'IOException
|
---|
| 83 | End If
|
---|
| 84 | End Function
|
---|
| 85 |
|
---|
| 86 | Function VolumeLabel() As String
|
---|
[142] | 87 | Dim volumeName[63] As TCAHR
|
---|
[64] | 88 | If GetVolumeInformation(m_DriveName, volumeName, 64, NULL, NULL, NULL, NULL, NULL) Then
|
---|
| 89 | Return volumeName
|
---|
| 90 | Else
|
---|
| 91 | 'IOException
|
---|
| 92 | End If
|
---|
| 93 | End Function
|
---|
[142] | 94 | End Class
|
---|
[271] | 95 |
|
---|
| 96 |
|
---|
| 97 | End Namespace
|
---|
| 98 | End Namespace
|
---|