FileLen 函数FileLen function

返回一个指定文件长度(以字节为单位)的 Long 值。Returns a Long specifying the length of a file in bytes.



必需的_pathname_ 参数是指定文件的字符串表达式The required pathname argument is a string expression that specifies a file. pathname 可以包括目录或文件夹以及驱动器。The pathname may include the directory or folder, and the drive.


如果在调用 FileLen 函数时指定的文件已打开,则返回的值表示在打开的前一刻该文件的大小。If the specified file is open when the FileLen function is called, the value returned represents the size of the file immediately before it was opened.


若要获取打开文件的长度, 请使用**LOF** 函数。To obtain the length of an open file, use the LOF function.


此示例使用 FileLen 函数返回文件的长度(以字节为单位)。This example uses the FileLen function to return the length of a file in bytes. 对于此示例,假定 TESTFILE 是包含某些数据的文件。For purposes of this example, assume that TESTFILE is a file containing some data.

Dim MySize
MySize = FileLen("TESTFILE")    ' Returns file length (bytes).

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.