Class StgStream
Storage API wrapper classes provide access to storage data from .NET code.
Inheritance
Implements
Namespace: Syncfusion.CompoundFile.XlsIO.Native
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public class StgStream : Stream, IDisposable
Constructors
StgStream()
Declaration
public StgStream()
Fields
DEF_READWRITE
Open storage or stream in ReadWrite mode.
Declaration
public const STGM DEF_READWRITE
Field Value
| Type |
|---|
| STGM |
DEF_STORAGE_READONLY
Options to open storage in read-only mode. Used to open already opened file.
Declaration
public const STGM DEF_STORAGE_READONLY
Field Value
| Type |
|---|
| STGM |
DEF_STORE_READONLY
Open storage in read-only mode.
Declaration
public const STGM DEF_STORE_READONLY
Field Value
| Type |
|---|
| STGM |
DEF_STREAM_CREATE
Create a new stream in storage.
Declaration
public const STGM DEF_STREAM_CREATE
Field Value
| Type |
|---|
| STGM |
DEF_STREAM_READONLY
Open storage stream in read-only mode.
Declaration
public const STGM DEF_STREAM_READONLY
Field Value
| Type |
|---|
| STGM |
Properties
CanRead
Indicates if stream supports Read operation. Read-only.
Declaration
public override bool CanRead { get; }
Property Value
| Type |
|---|
| System.Boolean |
CanSeek
Indicates if stream supports Seek operation. Read-only.
Declaration
public override bool CanSeek { get; }
Property Value
| Type |
|---|
| System.Boolean |
CanWrite
Indicates if stream supports Write operation. Read-only.
Declaration
public override bool CanWrite { get; }
Property Value
| Type |
|---|
| System.Boolean |
COMStorage
Reference in COM interface which provide access to storage.
Declaration
public IStorage COMStorage { get; }
Property Value
| Type |
|---|
| IStorage |
COMStream
Reference in COM interface which provide access to stream in storage.
Declaration
public IStream COMStream { get; }
Property Value
| Type |
|---|
| IStream |
FileName
Gets the file name.
Declaration
public string FileName { get; }
Property Value
| Type |
|---|
| System.String |
IsTransacted
Indicates if stream is opened in Transaction mode. Read-only.
Declaration
public bool IsTransacted { get; }
Property Value
| Type |
|---|
| System.Boolean |
Length
Length of stream. Read-only.
Declaration
public override long Length { get; }
Property Value
| Type |
|---|
| System.Int64 |
LockBytes
Gets the IlockBytes interface that represen the locked bytes.
Declaration
public ILockBytes LockBytes { get; }
Property Value
| Type |
|---|
| ILockBytes |
Position
Gets / sets current position of stream.
Declaration
public override long Position { get; set; }
Property Value
| Type |
|---|
| System.Int64 |
StorageName
Get name of sub storage opened by the class.
Declaration
public string StorageName { get; }
Property Value
| Type |
|---|
| System.String |
Storages
Gets the array of string thet is a storages.
Declaration
public string[] Storages { get; }
Property Value
| Type |
|---|
| System.String[] |
StreamName
Get name of stream opened by the class.
Declaration
public string StreamName { get; }
Property Value
| Type |
|---|
| System.String |
Streams
Gets list of stream names found in storage. Read-only.
Declaration
public string[] Streams { get; }
Property Value
| Type |
|---|
| System.String[] |
Methods
Commit(STGC)
Commit changes.
Declaration
public virtual void Commit(STGC code)
Parameters
| Type | Name | Description |
|---|---|---|
| STGC | code | Commit code. |
Exceptions
| Type | Condition |
|---|---|
| System.Runtime.InteropServices.ExternalException | When commit operation fails. |
ContainsStorage(String)
Indicates whether storage contains required substorage.
Declaration
public bool ContainsStorage(string strStorageName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | strStorageName | Storage to search. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if stream was found. |
ContainsStream(String)
Indicates whether storage contains required stream.
Declaration
public bool ContainsStream(string strStreamName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | strStreamName | Stream to search. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if stream was found. |
CopySourceStorages(StgStream, StgStream)
Copies one storage into another.
Declaration
public static void CopySourceStorages(StgStream source, StgStream destination)
Parameters
| Type | Name | Description |
|---|---|---|
| StgStream | source | Source stream. |
| StgStream | destination | Destination stream. |
CreateStream(String)
Create stream in opened storage with specified name.
Declaration
public void CreateStream(string streamName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | streamName | Stream name. |
CreateStream(String, STGM)
Create stream in storage with specified name and flags.
Declaration
public void CreateStream(string streamName, STGM streamFlags)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | streamName | Stream name. |
| STGM | streamFlags | Stream flags. |
Exceptions
| Type | Condition |
|---|---|
| System.Runtime.InteropServices.ExternalException | When its not possible to create stream. |
CreateSubStorage(String)
Creates sub storage.
Declaration
public StgStream CreateSubStorage(string storageName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | storageName | Storage name to Create. |
Returns
| Type | Description |
|---|---|
| StgStream | Returns stream of opened storage. |
CreateSubStorage(String, STGM)
Creates sub storage.
Declaration
public StgStream CreateSubStorage(string storageName, STGM flags)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | storageName | Storage name for create. |
| STGM | flags | Create flags. |
Returns
| Type | Description |
|---|---|
| StgStream | Returns stream for created storage. |
Dispose()
Dispose stream. Close stream, release references on COM interfaces, and free resources.
Declaration
public void Dispose()
FindStream(String)
Searches for stream name in the streams array ignoring case.
Declaration
public string FindStream(string strStreamName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | strStreamName | Stream name to locate. |
Returns
| Type | Description |
|---|---|
| System.String | Name of the stream in the storage. |
Flush()
Commit changes.
Declaration
public override void Flush()
OpenStream(String)
Open stream in Read-only mode.
Declaration
public void OpenStream(string streamName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | streamName | Stream name. |
OpenStream(String, STGM)
Open stream from storage with specified flags.
Declaration
public void OpenStream(string streamName, STGM streamFlags)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | streamName | Stream name. |
| STGM | streamFlags | Stream open flags. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | When streamName is NULL. |
| System.ArgumentException | When the specified stream could not be found in the storage. |
| System.Runtime.InteropServices.ExternalException | When it was not possible to open the stream. |
OpenSubStorage(String)
Opens sub storage.
Declaration
public StgStream OpenSubStorage(string storageName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | storageName | Storage name to open. |
Returns
| Type | Description |
|---|---|
| StgStream | Returns stream of opened storage. |
OpenSubStorage(String, STGM)
Opens sub storage.
Declaration
public StgStream OpenSubStorage(string storageName, STGM flags)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | storageName | Storage name to open. |
| STGM | flags | Open flags. |
Returns
| Type | Description |
|---|---|
| StgStream | Returns stream of opened storage. |
Read(Byte[], Int32, Int32)
Read data from stream.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | buffer | Output stream. |
| System.Int32 | offset | Offset in output buffer. |
| System.Int32 | count | Quantity of bytes to read. |
Returns
| Type | Description |
|---|---|
| System.Int32 | Quantity of read bytes. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | When buffer is NULL. |
| System.ArgumentOutOfRangeException | When offset or count is less than zero. |
| System.ArgumentException | When there are not enough items in the buffer. |
| System.Runtime.InteropServices.ExternalException | When Read operation fails. |
RemoveElement(String)
Removes the specified storage or stream from this storage object.
Declaration
public int RemoveElement(string elementName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | elementName | Name of the storage or stream to be removed. |
Returns
| Type | Description |
|---|---|
| System.Int32 | 0 - The element was successfully removed. Otherwise error code. |
Revert()
Discards all changes that have been made to the storage object since the last commit operation.
Declaration
public virtual void Revert()
SaveILockBytesIntoStream(Stream)
Saves internal ILockBytes into stream.
Declaration
public void SaveILockBytesIntoStream(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | stream | Stream to save into. |
Seek(Int64, SeekOrigin)
Seek in stream.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | offset | New offset. |
| System.IO.SeekOrigin | origin | Start point for Seek operation. |
Returns
| Type | Description |
|---|---|
| System.Int64 | Current position. |
Exceptions
| Type | Condition |
|---|---|
| System.Runtime.InteropServices.ExternalException | When seek operation fails. |
SetLength(Int64)
Set stream length.
Declaration
public override void SetLength(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int64 | value | New stream length |
Exceptions
| Type | Condition |
|---|---|
| System.Runtime.InteropServices.ExternalException | When SetLength operation fails. |
Write(Byte[], Int32, Int32)
Write data to stream.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | buffer | Buffer with data. |
| System.Int32 | offset | Offset in input buffer from which data started. |
| System.Int32 | count | Quantity of bytes which must be written. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | When buffer is NULL. |
| System.ArgumentOutOfRangeException | When offset or count is less than zero. |
| System.ArgumentException | When there are not enough items in the buffer or stream is in Read-only mode. |
| System.Runtime.InteropServices.ExternalException | When Write operation fails. |