FileStream.Length Propriedade

Definição

Obtém o tamanho do fluxo em bytes.

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

Valor da propriedade

Um valor longo que representa o tamanho do fluxo em bytes.

Exceções

CanSeek para esse fluxo é false.

Ocorreu um erro de E/S, como o arquivo ser fechado.

Exemplos

O exemplo a seguir usa as Length propriedades e Position para marcar para uma condição de fim de arquivo.

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
    printfn "End of file has been reached."
If s.Length = s.Position Then
    Console.WriteLine("End of file has been reached.")
End If

Comentários

Para obter uma lista de operações comuns de arquivo e diretório, consulte Tarefas comuns de E/S.

Aplica-se a

Confira também