Sorry,
I think that this is a very easy question, I just want to know how you can get the file size of a file using vb code.
Any source would be great
Thanks
Hurgh
Printable View
Sorry,
I think that this is a very easy question, I just want to know how you can get the file size of a file using vb code.
Any source would be great
Thanks
Hurgh
By using the FileLen function:
Code:MsgBox "The file size is " & FileLen("C:\MyFile.txt")
Dim FilePath As String
Dim LengthOfFile As Long
Open FilePath For Binary As #1
LengthOfFile = LOF(1)
Close #1
FilePath is the path and filename of the file you want to know the size of e.g c:\io.sys
LengthOfFile is exactly what it says it is, the length of the file in bytes. Past that
1 KiloByte = 1024 Bytes
1 MegaByte = 1024 Kb
1 Gigabyte = 1024 Mb
Hope this helps you,