O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

LOF Function

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required