
|
| |  |  | End Of Month |
|
|
| |  |  | First Of Last Month |
|
|
| |  |  | Make Directory |
|
|
Get File Size
Home :: Visual Basic :: Get Filesize
Here's a simple Visual Basic function you can use in Vb6+/MS Access to get the size of a file in KiloBytes.
Also requires: Directory related Constants to be declared in the same module
and File Errors Handler
Public
Function
FileSize(ByVal FileName As String) As Long 'Returns
the size of a file in KiloBytes Dim dl As Long Dim Msg As String Dim myFileInfo As
BY_HANDLE_FILE_INFORMATION On Local Error GoTo FileSize_Err 'TO DO return Bytes or
KB
If FileName = "" Then Exit Function Else hFile& =
CreateFile&(FileName$, GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0,
0) dl& =
GetFileInformationByHandle&(hFile&,
myFileInfo) With
myFileInfo FileSize = CStr(.nFileSizeLow) \
1000 End With dl&
= CloseHandle&(hFile&) End If If FileSize = 0 Then FileSize =
1 End If
FileSize_End:
Exit
Function
FileSize_Err:
Resume
FileSize_End
End Function |
Please Link to us
Next >> Recycle Bin
|