Name
FileLen Function
Class
Microsoft.VisualBasic.FileSystem
Syntax
FileLen(pathname
)
-
pathname
(required; 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, FileLen generates runtime error 53, “File not found.”
Because FileLen returns the length of a file based on the file allocation table, the value returned by FileLen will reflect 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
Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.