Breyta

Deila með


FileStream.Position Property

Definition

Gets or sets the current position of this stream.

public:
 virtual property long Position { long get(); void set(long value); };
public override long Position { get; set; }
member this.Position : int64 with get, set
Public Overrides Property Position As Long

Property Value

The current position of this stream.

Exceptions

The stream does not support seeking.

An I/O error occurred.

Attempted to set the position to a negative value.

Attempted seeking past the end of a stream that does not support this.

Examples

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

Remarks

Seeking to any location beyond the length of the stream is supported. When you seek beyond the length of the file, the file size grows. Any data added to the end of the file is set to zero.

For a list of common file and directory operations, see Common I/O Tasks.

Applies to

See also