來源:http://www.blueshop.com.tw/board/show.asp?subcde=BRD200607311444336E3&fumcde=FUM20050124191756KKC&odr=cdt&odrtyp=0
Imports System.Runtime.InteropServices
<DllImport("Kernel32")> _
Public Shared Function GetDiskFreeSpaceEx(ByVal lpDirectoryName As String, ByRef lpFreeBytesAvailable As UInt64, ByRef lpTotalNumberOfBytes As UInt64, ByRef lpTotalNumberOfFreeBytes As UInt64) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
Private Function GetFreeDiskSpace(ByVal driveLetter As String) As UInt64
Dim freespace As UInt64
If GetDiskFreeSpaceEx(driveLetter, Nothing, Nothing, freespace) Then
Return freespace
Else
Return New UInt64
End If
End Function
Dim dirName As String = "C:\"
MessageBox.Show(String.Format("{0} 目前尚有 {1} 個位元組的可用空間", dirName, GetFreeDiskSpace(dirName)))
----------------------------------------------------------------------------
Dim cdrive As System.IO.DriveInfo
cdrive = My.Computer.FileSystem.GetDriveInfo("C:\")
MsgBox("Total free space: " & CStr(cdrive.TotalFreeSpace))
沒有留言:
張貼留言