Class StgStream
Storage API wrapper classes provide access to storage data from .NET code.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.CompoundFile.DocIO.Native
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class StgStream : Stream, IDisposable
Constructors
StgStream(StgStream, String)
Inherit stream storage and opens its stream in Read-only mode.
Declaration
public StgStream(StgStream storage, string streamName)
Parameters
Type | Name | Description |
---|---|---|
StgStream | storage | Storage of stream. |
System.String | streamName | Stream name to open. |
StgStream(StgStream, String, STGM)
Inherit stream storage and opensits streams with the user specified flags.
Declaration
public StgStream(StgStream storage, string streamName, STGM streamFlags)
Parameters
Type | Name | Description |
---|---|---|
StgStream | storage | Storage to inherit. |
System.String | streamName | Stream name. |
STGM | streamFlags | Stream open flags. |
StgStream(StgStream, String, STGM, Boolean)
Inherit storage and open or create in it stream with spcified user name
Declaration
public StgStream(StgStream storage, string streamName, STGM streamFlags, bool bCreate)
Parameters
Type | Name | Description |
---|---|---|
StgStream | storage | Inherited storage. |
System.String | streamName | Stream name. |
STGM | streamFlags | Stream open / create flags. |
System.Boolean | bCreate | True to create stream; otherwise open. |
StgStream(StgStream, String, Boolean)
Open or create stream specified by user name.
Declaration
public StgStream(StgStream storage, string streamName, bool bCreate)
Parameters
Type | Name | Description |
---|---|---|
StgStream | storage | Inherited storage. |
System.String | streamName | Stream name. |
System.Boolean | bCreate | True to create stream; otherwise open. |
StgStream(Stream)
Create a new instance of StgStream by defoult flag.
Declaration
public StgStream(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Base stream. |
StgStream(Stream, STGM)
Create a new instance of StgStream.
Declaration
public StgStream(Stream stream, STGM flags)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Base stream. |
STGM | flags | Flags for create stream. |
StgStream(String)
Open storage in Read-only mode but do not open stream. To open special stream, use OpenStream methods.
Declaration
public StgStream(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Storage file name. |
StgStream(String, STGM)
Open storage/compound file.
Declaration
public StgStream(string fileName, STGM flags)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | File name of storage. |
STGM | flags | Mode which must be used for open operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | When fileName is NULL. |
System.Runtime.InteropServices.ExternalException | Couldn't open the storage |
StgStream(String, STGM, String, STGM)
Open storage and one stream of it.
Declaration
public StgStream(string fileName, STGM storeFlags, string streamName, STGM streamFlags)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | File name of storage. |
STGM | storeFlags | Flags that are used for storage open. |
System.String | streamName | Stream name. |
STGM | streamFlags | Flags which used for stream in storage open. |
StgStream(String, String)
Open storage and its stream in Read-only mode.
Declaration
public StgStream(string fileName, string streamName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | File name. |
System.String | streamName | Stream name. |
Fields
DEF_READWRITE
Open storage or stream in ReadWrite mode.
Declaration
public const STGM DEF_READWRITE = STGM.STGM_READWRITE | STGM.STGM_SHARE_EXCLUSIVE
Field Value
Type | Description |
---|---|
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 = STGM.STGM_SHARE_DENY_NONE | STGM.STGM_DIRECT_SWMR
Field Value
Type | Description |
---|---|
STGM |
DEF_STORE_READONLY
Open storage in read-only mode.
Declaration
public const STGM DEF_STORE_READONLY = STGM.STGM_SHARE_DENY_WRITE
Field Value
Type | Description |
---|---|
STGM |
DEF_STREAM_CREATE
Create a new stream in storage.
Declaration
public const STGM DEF_STREAM_CREATE = STGM.STGM_READWRITE | STGM.STGM_SHARE_EXCLUSIVE | STGM.STGM_CREATE
Field Value
Type | Description |
---|---|
STGM |
DEF_STREAM_READONLY
Open storage stream in read-only mode.
Declaration
public const STGM DEF_STREAM_READONLY = STGM.STGM_SHARE_EXCLUSIVE
Field Value
Type | Description |
---|---|
STGM |
Properties
CanRead
Indicates if stream supports Read operation. Read-only.
Declaration
public override bool CanRead { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
CanSeek
Indicates if stream supports Seek operation. Read-only.
Declaration
public override bool CanSeek { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
CanWrite
Indicates if stream supports Write operation. Read-only.
Declaration
public override bool CanWrite { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
COMStorage
Reference in COM interface which provide access to storage.
Declaration
[CLSCompliant(false)]
public IStorage COMStorage { get; }
Property Value
Type | Description |
---|---|
IStorage |
COMStream
Reference in COM interface which provide access to stream in storage.
Declaration
[CLSCompliant(false)]
public IStream COMStream { get; }
Property Value
Type | Description |
---|---|
IStream |
FileName
Gets the file name.
Declaration
public string FileName { get; }
Property Value
Type | Description |
---|---|
System.String |
IsTransacted
Indicates if stream is opened in Transaction mode. Read-only.
Declaration
public bool IsTransacted { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Length
Length of stream. Read-only.
Declaration
public override long Length { get; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
LockBytes
Gets the IlockBytes interface that represen the locked bytes.
Declaration
[CLSCompliant(false)]
public ILockBytes LockBytes { get; }
Property Value
Type | Description |
---|---|
ILockBytes |
Position
Gets / sets current position of stream.
Declaration
public override long Position { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Overrides
StorageName
Get name of sub storage opened by the class.
Declaration
public string StorageName { get; }
Property Value
Type | Description |
---|---|
System.String |
Storages
Gets the array of string thet is a storages.
Declaration
public string[] Storages { get; }
Property Value
Type | Description |
---|---|
System.String[] |
StreamName
Get name of stream opened by the class.
Declaration
public string StreamName { get; }
Property Value
Type | Description |
---|---|
System.String |
Streams
Gets list of stream names found in storage. Read-only.
Declaration
public string[] Streams { get; }
Property Value
Type | Description |
---|---|
System.String[] |
Methods
Close()
Closes the stream.
Declaration
public override void Close()
Overrides
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. |
CreateStorage(String)
Method to create new storage and return StgStream class for it.
Declaration
public static StgStream CreateStorage(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Storage file name. |
Returns
Type | Description |
---|---|
StgStream | Reference on instance which knows how to work with it. |
Exceptions
Type | Condition |
---|---|
System.Runtime.InteropServices.ExternalException | When compound file couldn't be created. |
CreateStorageOnILockBytes()
Cretes storage on ILockBytes.
Declaration
public static StgStream CreateStorageOnILockBytes()
Returns
Type | Description |
---|---|
StgStream | Created storage. |
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()
Overrides
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. |
Overrides
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. |
Overrides
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 |
Overrides
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. |
Overrides
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. |