FileStream.Length FileStream.Length FileStream.Length FileStream.Length Property

定义

获取用字节表示的流长度。Gets the length in bytes of the stream.

public:
 virtual property long Length { long get(); };
public override long Length { get; }
member this.Length : int64
Public Overrides ReadOnly Property Length As Long

属性值

表示流长度(以字节为单位)的长值。A long value representing the length of the stream in bytes.

异常

出现 I/O 错误,例如文件被关闭。An I/O error, such as the file being closed, occurred.

示例

下面的示例使用LengthPosition属性以检查是否为文件尾条件。The following example uses the Length and Position properties to check for an end-of-file condition.

if ( s->Length == s->Position )
{
   Console::WriteLine( "End of file has been reached." );
}
if( s.Length==s.Position )
{
   Console.WriteLine("End of file has been reached.");
}
If s.Length = s.Position Then
    Console.WriteLine("End of file has been reached.")
End If

注解

常见的文件和目录操作的列表,请参阅通用 I/O 任务For a list of common file and directory operations, see Common I/O Tasks.

适用于

另请参阅