Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
This code will allow you get the free disk space on a drive which is over 2 Gb in size. Put all this code into a module
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, ByRef lpFreeBytesAvailableToCaller As Long, ByRef lpTotalNumberOfBytes As Long, ByRef lpTotalNumberOfFreeBytes As Long) As Long
Public Function GetFreeSpace(ByVal Drive As String) As Long
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable, iAns As Long
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, lBytesTotal, lFreeBytes)
If iAns > 0 Then
Return BytesToMegabytes(lFreeBytes)
Else
Throw New Exception("Kon niet lezen van deze schijf")
End If
End Function
Public Function GetTotalSpace(ByVal Drive As String) As String
Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable, iAns As Long
iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, lBytesTotal, lFreeBytes)
If iAns > 0 Then
Return BytesToMegabytes(lBytesTotal)
Else
Throw New Exception("Kon niet lezen van deze schijf")
End If
End Function
Public Function BytesToMegabytes(ByVal Bytes As Long) As Long
Dim dblAns As Decimal
dblAns = Bytes / 1024 ^ TrackBarEenheid.Value
Return Math.Round(dblAns, 2)
End Function
Maak eens van alle "Longs" het type "Decimal"
Public Class Form1
Public ReadOnly Property DriveSize(ByVal DriveLetter As String, ByVal _Size As SizeText) As String
Get
Dim DI As New IO.DriveInfo(DriveLetter)
Dim Space As String = DI.AvailableFreeSpace
Select Case _Size.ToString
Case "KB"
Space = Format((Space / 1024), "0.0") & " KB"
Case "MB"
Space = Format(((Space / 1024) / 1024), "0.0") & " MB"
Case "GB"
Space = Format((((Space / 1024) / 1024) / 1024), "0.0") & " GB"
Case "TB"
Space = Format(((((Space / 1024) / 1024) / 1024) / 1024), "0.0") & " TB"
End Select
Return Space
End Get
End Property
Public Enum SizeText
TB
GB
MB
KB
End Enum
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As String = DriveSize("c:\", SizeText.MB)
End Sub
End Class
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.