tayleeming
asked on
Determine a file size
Hi,
1) i wish to know how can i get size of a file that specify by user in VB,and return the size in MB unit to the user. please provide me with a working example. Thanks
1) i wish to know how can i get size of a file that specify by user in VB,and return the size in MB unit to the user. please provide me with a working example. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
btw, in the above code, u can ignore putting the 2 functions GetFileTime, MoveFile.
n at the end of the code, u can close file handle
CloseHandle(lngHandle) 'This will close the handle of the file after finishing.
wish ya luck again :)
n at the end of the code, u can close file handle
CloseHandle(lngHandle) 'This will close the handle of the file after finishing.
wish ya luck again :)
For a file open with a file number, use LOF(FileNumber).
For a file that's not open, use FileLen(Path).
Both return the file size in bytes as a LONG.
For example:
MsgBox("File size in MB is "+str(FileLen("c:\thingy.f oo")/10000 00))
For a file that's not open, use FileLen(Path).
Both return the file size in bytes as a LONG.
For example:
MsgBox("File size in MB is "+str(FileLen("c:\thingy.f
msgbox format$(filelen("c:\myfile .xxx")/102 4/1024 ,##.0") & "Mb"
here's a sample code:
--------------------------
Declare Function GetFileSize Lib "kernel32" Alias "GetFileSize" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
· hFile
Specifies an open handle of the file whose size is being returned. The handle must have been created with either GENERIC_READ or GENERIC_WRITE access to the file.
· lpFileSizeHigh
Points to the variable where the high-order word of the file size is returned. This parameter can be NULL if the application does not require the high-order word.
--------------------------