| FileLen Function |
Named Arguments
No
Syntax
FileLen(pathname)
Pathname
Use: Required
Data Type: String
The filename, optionally along with its path and drive.
Return Value
A Long data type containing the length of the specified file in bytes.
Description
Indicates the length of a file.
Rules at a Glance
If you don't specify a drive or folder with filename, the file is assumed to be in the current drive or folder.
Programming Tips and Gotchas
Use the Dir function to determine that the file exists before calling File-DateTime. If the file doesn't exist, FileDateTime generates runtime error 53, "File not found." Another method of determining that a file exists before referencing it comes from the new FileSystemObject object in VB6, which includes a FileExists method.
Because FileLen returns the length of a file based on the file allocation table, the value returned by FileLen reflects the size of the file before it was opened. In the case of open files, you should instead use the LOF function to determine the open file's current length.
See Also
- FileDateTime Function, LOF Function, File System Objects
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access