File exists or not:
The info about the drive:Code:Function Existfile(ByVal sFile As String) As Boolean Dim szResults As String On Error GoTo Not_ExistFile szResults = Dir$(sFile) If szResults = "" Then Existfile = False Else Existfile = True End If Exit Function Not_ExistFile: Existfile = False Exit Function End Function
Code:'// Make a New project. Add a module. To the form Add a Command button. '// Code: '// Add this code To the module: Option Explicit Public Type DRIVE_INFO DrvSectors As Long DrvBytesPerSector As Long DrvFreeClusters As Long DrvTotalClusters As Long DrvSpaceFree As Long DrvSpaceUsed As Long DrvSpaceTotal As Long End Type Public Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" _ (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Public Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" _ (ByVal lpRootPathName As String, _ lpSectorsPerCluster As Long, _ lpBytesPerSector As Long, _ lpNumberOfFreeClusters As Long, _ lpTotalNumberOfClusters As Long) As Long '// Add this code To the Command button: Private Sub Command1_Click() Dim RDI As DRIVE_INFO Dim r As Long Dim RootPathName As String RootPathName$ = "C:\" r& = rgbGetDiskFreeSpaceRDI(RootPathName$, RDI) Cls Print Print " Drive Statistics for ", ": "; UCase$(RootPathName$) Print Print " No of Sectors", ": "; RDI.DrvSectors Print " Bytes per sector", ": "; RDI.DrvBytesPerSector Print " Clusters Free", ": "; RDI.DrvFreeClusters Print " Total Clusters", ": "; RDI.DrvTotalClusters Print " Drive Space Used", ": "; Format$(RDI.DrvSpaceUsed, "###,###,###,##0") & " bytes" Print " Drive Space Free", ": "; Format$(RDI.DrvSpaceFree, "###,###,###,##0") & " bytes" Print " Total Drive Size", ": "; Format$(RDI.DrvSpaceTotal, "###,###,###,##0") & " bytes" End Sub '// Add this code To the form's General Declarations procedure: Private Function rgbGetDiskFreeSpaceRDI(RootPathName$, RDI As DRIVE_INFO) As Long Dim r As Long r& = GetDiskFreeSpace(RootPathName$, RDI.DrvSectors, RDI.DrvBytesPerSector, RDI.DrvFreeClusters, RDI.DrvTotalClusters) RDI.DrvSpaceTotal = (RDI.DrvSectors * RDI.DrvBytesPerSector * RDI.DrvTotalClusters) RDI.DrvSpaceFree = (RDI.DrvSectors * RDI.DrvBytesPerSector * RDI.DrvFreeClusters) RDI.DrvSpaceUsed = RDI.DrvSpaceTotal - RDI.DrvSpaceFree rgbGetDiskFreeSpaceRDI& = r& End Function




Reply With Quote