System.IO.FileStream Members

The members of System.IO.FileStream are listed below.

See Also: Inherited members from System.IO.Stream

Public Constructors

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission.

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission.

Initializes a new instance of the System.IO.FileStream class with the specified path and creation mode.

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission, and buffer size.

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission and FileStream instance ownership.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, and read/write permission.

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission, buffer size, and synchronous or asynchronous state.

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission, FileStream instance ownership, and buffer size.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, read/write permission, and sharing permission.

Initializes a new instance of the System.IO.FileStream class for the specified file handle, with the specified read/write permission, FileStream instance ownership, buffer size, and synchronous or asynchronous state.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, read/write and sharing permission, and buffer size.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, read/write and sharing permission, buffer size, and synchronous or asynchronous state.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, read/write and sharing permission, the access other FileStreams can have to the same file, the buffer size, and additional file options.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, access rights and sharing permission, the buffer size, and additional file options.

Initializes a new instance of the System.IO.FileStream class with the specified path, creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security.

Public Properties

[read-only]
override
CanReadbool.

Gets a value indicating whether the current stream supports reading.

[read-only]
override
CanSeekbool.

Gets a value indicating whether the current stream supports seeking.

[read-only]
override
CanWritebool.

Gets a value indicating whether the current stream supports writing.

[read-only]
HandleIntPtr.

Gets the operating system file handle for the file that the current FileStream object encapsulates.

[read-only]
IsAsyncbool.

Gets a value indicating whether the FileStream was opened asynchronously or synchronously.

[read-only]
override
Lengthlong.

Gets the length in bytes of the stream.

[read-only]
Namestring.

Gets the name of the FileStream that was passed to the constructor.

override
Positionlong.

Gets or sets the current position of this stream.

[read-only]
SafeFileHandleMicrosoft.Win32.SafeHandles.SafeFileHandle.

Gets a Microsoft.Win32.SafeHandles.SafeFileHandle object that represents the operating system file handle for the file that the current System.IO.FileStream object encapsulates.

Public Methods

override
BeginRead(byte[], int, int, AsyncCallback, object) : IAsyncResult

Begins an asynchronous read operation. (Consider using FileStream.ReadAsync(Byte[], int, int, System.Threading.CancellationToken) instead; see the Remarks section.)

override
BeginWrite(byte[], int, int, AsyncCallback, object) : IAsyncResult

Begins an asynchronous write operation. (Consider using FileStream.WriteAsync(Byte[], int, int, System.Threading.CancellationToken) instead; see the Remarks section.)

override
Close()
Closes the file and releases any resources associated with the current file stream.
override
EndRead(IAsyncResult) : int

Waits for the pending asynchronous read operation to complete. (Consider using FileStream.ReadAsync(Byte[], int, int, System.Threading.CancellationToken) instead; see the Remarks section.)

override
EndWrite(IAsyncResult)

Ends an asynchronous write operation and blocks until the I/O operation is complete. (Consider using FileStream.WriteAsync(Byte[], int, int, System.Threading.CancellationToken) instead; see the Remarks section.)

Finalize()

Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the FileStream.

override
Flush()

Clears buffers for this stream and causes any buffered data to be written to the file.

Flush(bool)

Clears buffers for this stream and causes any buffered data to be written to the file, and also clears all intermediate file buffers.

override
FlushAsync(System.Threading.CancellationToken) : System.Threading.Tasks.Task

Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

GetAccessControl() : System.Security.AccessControl.FileSecurity

Gets a System.Security.AccessControl.FileSecurity object that encapsulates the access control list (ACL) entries for the file described by the current System.IO.FileStream object.

Lock(long, long)

Prevents other processes from reading from or writing to the System.IO.FileStream.

override
Read(byte[], int, int) : int

Reads a block of bytes from the stream and writes the data in a given buffer.

override
ReadAsync(byte[], int, int, System.Threading.CancellationToken) : System.Threading.Tasks.Task<int>

Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

override
ReadByte() : int

Reads a byte from the file and advances the read position one byte.

override
Seek(long, SeekOrigin) : long

Sets the current position of this stream to the given value.

SetAccessControl(System.Security.AccessControl.FileSecurity)

Applies access control list (ACL) entries described by a System.Security.AccessControl.FileSecurity object to the file described by the current System.IO.FileStream object.

override
SetLength(long)

Sets the length of this stream to the given value.

Unlock(long, long)

Allows access by other processes to all or part of a file that was previously locked.

override
Write(byte[], int, int)

Writes a block of bytes to the file stream.

override
WriteAsync(byte[], int, int, System.Threading.CancellationToken) : System.Threading.Tasks.Task

Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

override
WriteByte(byte)

Writes a byte to the current position in the file stream.

Protected Methods

override
Dispose(bool)

Releases the unmanaged resources used by the System.IO.FileStream and optionally releases the managed resources.