Class FileStream
- Namespace
- CMS.FileSystemStorage
- Assembly
- CMS.IO.dll
Envelope for FileStream classes (System.IO).
public class FileStream : FileStream
- Inheritance
-
objectMarshalByRefObjectStreamFileStream
- Inherited Members
- Extension Methods
Constructors
FileStream(FileStream)
Initializes new instance and intializes new system file stream.
public FileStream(FileStream fs)
Parameters
fsFileStreamFile stream
FileStream(string, FileMode)
Initializes new instance and intializes new system file stream.
public FileStream(string path, FileMode mode)
Parameters
pathstringPath to file
modeFileModeFile mode
FileStream(string, FileMode, FileAccess)
Initializes new instance and intializes new system file stream.
public FileStream(string path, FileMode mode, FileAccess access)
Parameters
pathstringPath to file
modeFileModeFile mode
accessFileAccessFile access
FileStream(string, FileMode, FileAccess, FileShare)
Initializes new instance and intializes new system file stream.
public FileStream(string path, FileMode mode, FileAccess access, FileShare share)
Parameters
pathstringPath to file
modeFileModeFile mode
accessFileAccessFile access
shareFileShareSharing permissions
FileStream(string, FileMode, FileAccess, FileShare, int)
Initializes new instance and intializes new system file stream.
public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
Parameters
pathstringPath to file
modeFileModeFile mode
accessFileAccessFile access
shareFileShareSharing permissions
bufferSizeintBuffer size
Properties
CanRead
Gets a value indicating whether the current stream supports reading.
public override bool CanRead { get; }
Property Value
- bool
CanSeek
Gets a value indicating whether the current stream supports seeking.
public override bool CanSeek { get; }
Property Value
- bool
True if the stream supports seeking, false otherwise.
CanWrite
Gets a value indicating whether the current stream supports writing.
public override bool CanWrite { get; }
Property Value
- bool
Length
Gets the length in bytes of the stream.
public override long Length { get; }
Property Value
- long
Position
Gets or sets the position within the current stream.
public override long Position { get; set; }
Property Value
- long
Methods
Close()
Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream.
public override void Close()
Dispose(bool)
Releases all unmanaged and optionally managed resources.
protected override void Dispose(bool disposing)
Parameters
disposingboolWhen true, managed resources are released.
Flush()
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public override void Flush()
FlushAsync(CancellationToken)
Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.
public override Task FlushAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
Read(byte[], int, int)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override int Read(byte[] array, int offset, int count)
Parameters
arraybyte[]The buffer to write the data into.
offsetintThe byte offset in
arrayat which to begin writing data from the stream.countintThe maximum number of bytes to read.
Returns
- int
ReadAsync(byte[], int, int, CancellationToken)
Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
bufferbyte[]The buffer to write the data into.
offsetintThe byte offset in
bufferat which to begin writing data from the stream.countintThe maximum number of bytes to read.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<int>
Seek(long, SeekOrigin)
Sets cursor position at specified position.
public override long Seek(long offset, SeekOrigin loc)
Parameters
offsetlongOffset from beginning of file
locSeekOriginSeek origin
Returns
- long
SetLength(long)
Sets the length of the current stream.
public override void SetLength(long value)
Parameters
valuelongThe desired length of the current stream in bytes.
Write(byte[], int, int)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
public override void Write(byte[] buffer, int offset, int count)
Parameters
bufferbyte[]The buffer to write data from.
offsetintThe zero-based byte offset in
bufferfrom which to begin copying bytes to the stream.countintThe maximum number of bytes to write.
WriteAsync(byte[], int, int, CancellationToken)
Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
bufferbyte[]The buffer to write data from.
offsetintThe zero-based byte offset in
bufferfrom which to begin copying bytes to the stream.countintThe maximum number of bytes to write.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
WriteByte(byte)
Writes byte to stream.
public override void WriteByte(byte value)
Parameters
valuebyteValue to write