FileStream.Length Proprietà

Definizione

Ottiene la lunghezza in byte del flusso.

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

Valore della proprietà

Valore long che rappresenta la lunghezza del flusso in byte.

Eccezioni

CanSeek per questo flusso è false.

Si è verificato un errore I/O, ad esempio il file viene chiuso.

Esempio

Nell'esempio seguente vengono utilizzate le Length proprietà e Position per verificare la presenza di una condizione di fine file.

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

Commenti

Per un elenco delle operazioni comuni di file e directory, vedere Attività di I/O comuni.

Si applica a

Vedi anche