Name
FileLen Function
Class
Microsoft.VisualBasic.FileSystem
Syntax
FileLen(pathname)-
pathname Use: Required
Data Type: String
The filename, along with its path and drive name (optionally)
Return Value
A Long containing the length of the specified file in bytes
Description
Specifies the length of a file on disk
Rules at a Glance
If you don’t specify a drive or folder with
pathname, the file is assumed to be in the
current drive or folder.
Programming Tips and Gotchas
Use the File.Exists method in the System.IO namespace to determine that the file exists before calling
FileLen. If the file does not exist,FileLengenerates runtime error 53, “File not found.”Because
FileLenreturns the length of a file based on the file allocation table, the value returned byFileLenwill reflect the size of the file before it was opened. In the case of open files, you should instead use theLOFfunction to determine the open file’s current length.
See Also
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