FileSystem.FileLen(String) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a value that specifies the length of a file in bytes. The My
feature gives you better productivity and performance in file I/O operations than FileLen
. For more information, see GetFileInfo(String).
public:
static long FileLen(System::String ^ PathName);
public static long FileLen(string PathName);
static member FileLen : string -> int64
Public Function FileLen (PathName As String) As Long
- PathName
- String
Required. A string expression that specifies a file. PathName
may include the directory or folder, and the drive.
The length of a file in bytes.
File does not exist.
This example uses the FileLen
function to return the length of a file in bytes. For purposes of this example, assume that TestFile
is a file that contains some data.
Dim MySize As Long
' Returns file length (bytes).
MySize = FileLen("TESTFILE")
If the specified file is open when the FileLen
function is called, the value returned represents the size of the file at the time it was opened.
Note
To obtain the current length of an open file, use the LOF
function.
Product | Versions |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: