|
|
Please support our sponsor:
Get File Size
This is an easy way to get the file size of any file a user
might select. Lets assume you have a form with a directory
list box called mydir and a file list box named myfile.
The user can scroll to any directory on their hard drive,
select a file from the file list box and the program will
tell them the size of that file. Heres the code:
Private Sub cmdShowFileSize_Click()
Dim strOldFile As String
Dim strOldSize As String
Dim strMyDir As String
Dim strMyFile As String
'Update the following with your directory and file
'info or use App.Path. This sample does not include
'error checking.
strMyDir = "c:\windows\desktop"
strMyFile = "readme.txt"
strOldFile = strMyDir & "\" & strMyFile
strOldSize = FileLen(strOldFile)
lblFileSize.Caption = "The file " & strOldFile & " is " & _
Format(strOldSize, "#,##0") & " bytes in size."
End Sub
--------------------------------------------------------------------
Note: Code updated by Burt Abreu from an original
tip submitted by Greg Kamer at gkamer@agritel.net
--------------------------------------------------------------------
Download VB6 Sample
|