Class UnifiedFileStream
System.IO.Stream implementation for file streams returned by the UnifiedFile implemetation. All operations are executed on a wrapped inner stream.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Web.Hosting
Assembly: EPiServer.dll
Version: 8.11.0Syntax
public class UnifiedFileStream : Stream, IDisposable
Properties
CanRead
Gets a value indicating whether the current stream supports reading.
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
CanSeek
Gets a value indicating whether the current stream supports seeking.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
CanWrite
Gets a value indicating whether the current stream supports writing.
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
Length
Gets the length in bytes of the stream.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | A class derived from Stream does not support seeking. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
Position
Gets or sets the position within the current stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
Exceptions
Type | Condition |
---|---|
System.IO.IOException | An I/O error occurs. |
System.NotSupportedException | The stream does not support seeking. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
Methods
Close()
Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. Raises the EPiServer.Web.Hosting.UnifiedFile.OnFileChanged(EPiServer.Web.Hosting.UnifiedFileStream,EPiServer.Web.Hosting.UnifiedVirtualPathEventArgs) for non-empty streams.
Declaration
public override void Close()
Overrides
Flush()
Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
Declaration
public override void Flush()
Overrides
Exceptions
Type | Condition |
---|---|
System.IO.IOException | An I/O error occurs. |
Read(Byte[], Int32, Int32)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. |
System.Int32 | offset | The zero-based byte offset in buffer at which to begin storing the data read from the current stream. |
System.Int32 | count | The maximum number of bytes to be read from the current stream. |
Returns
Type | Description |
---|---|
System.Int32 | The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. |
Overrides
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The sum of offset and count is larger than the buffer length. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
System.NotSupportedException | The stream does not support reading. |
System.ArgumentNullException | buffer is null. |
System.IO.IOException | An I/O error occurs. |
System.ArgumentOutOfRangeException | offset or count is negative. |
ReadByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
Declaration
public override int ReadByte()
Returns
Type | Description |
---|---|
System.Int32 | The unsigned byte cast to an Int32, or -1 if at the end of the stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The stream does not support reading. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
Seek(Int64, SeekOrigin)
Sets the position within the current stream.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | offset | A byte offset relative to the origin parameter. |
System.IO.SeekOrigin | origin | A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position. |
Returns
Type | Description |
---|---|
System.Int64 | The new position within the current stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.IO.IOException | An I/O error occurs. |
System.NotSupportedException | The stream does not support seeking, such as if the stream is constructed from a pipe or console output. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
SetLength(Int64)
Sets the length of the current stream.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The desired length of the current stream in bytes. |
Overrides
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The stream does not support both writing and seeking, such as if the stream is constructed from a pipe or console output. |
System.IO.IOException | An I/O error occurs. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
Write(Byte[], Int32, Int32)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | An array of bytes. This method copies count bytes from buffer to the current stream. |
System.Int32 | offset | The zero-based byte offset in buffer at which to begin copying bytes to the current stream. |
System.Int32 | count | The number of bytes to be written to the current stream. |
Overrides
Exceptions
Type | Condition |
---|---|
System.IO.IOException | An I/O error occurs. |
System.NotSupportedException | The stream does not support writing. |
System.ObjectDisposedException | Methods were called after the stream was closed. |
System.ArgumentNullException | buffer is null. |
System.ArgumentException | The sum of offset and count is greater than the buffer length. |
System.ArgumentOutOfRangeException | offset or count is negative. |