1  Namespace System


2  Namespace IO


3 


4 


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


41  Dim systemName[15] As TCHAR


42  If GetVolumeInformation(m_DriveName, NULL, 0, NULL, NULL, NULL, systemName, Len (systemName)) Then


43  Dim resultStr = New String( systemName )


44  Return resultStr


45  Else


46  'IOException


47  End If


48  End Function


49 


50  Function DriveType() As Long


51  Return GetDriveType(m_DriveName)


52  End Function


53 


54  Function IsReady() As Boolean


55  If GetVolumeInformation(m_DriveName, NULL, 0, NULL, NULL, NULL, NULL, 0) Then


56  Return True


57  Else


58  Return False


59  End If


60  End Function


61 


62  Function Name() As String


63  Return m_DriveName


64  End Function


65 


66  /* Function RootDirectory() As DirectoryInfo


67  End Function*/


68 


69  Function TotalFreeSpace() As QWord


70  Dim totalFreeSpace As ULARGE_INTEGER


71  If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, ByVal 0, totalFreeSpace) Then


72  Return (totalFreeSpace.HighPart << 32) Or totalFreeSpace.LowPart


73  Else


74  'IOException


75  End If


76  End Function


77 


78  Function TotalSize() As QWord


79  Dim totalSize As ULARGE_INTEGER


80  If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, totalSize, ByVal 0) Then


81  Return (totalSize.HighPart << 32) Or totalSize.LowPart


82  Else


83  'IOException


84  End If


85  End Function


86 


87  Function VolumeLabel() As String


88  Dim volumeName[63] As TCHAR


89  If GetVolumeInformation(m_DriveName, volumeName, 64, NULL, NULL, NULL, NULL, 0) Then


90  Dim resultStr = New String( volumeName )


91  Return resultStr


92  Else


93  'IOException


94  End If


95  End Function


96  End Class


97 


98 


99  End Namespace


100  End Namespace

