OpenMcdf Namespace

Open MCDF
OpenMcdf Namespace
Namespaces ► OpenMcdf
Open MCDF
Declaration Syntax
C# Visual Basic Visual C++
namespace OpenMcdf
Namespace OpenMcdf
namespace OpenMcdf
Types
All Types Classes Enumerations Delegates
Icon | Type | Description
 | CFDisposedException | Raised when a data setter/getter method is invoked on a stream or storage object after the disposal of the owner compound file object.
 | CFDuplicatedItemException | Raised when trying to add a duplicated CFItem
 | CFException | OpenMCDF base exception.
 | CFFileFormatException | Raised when opening a file with invalid header or not supported COM/OLE Structured storage version.
 | CFInvalidOperation | Raised when a method call is invalid for the current object state
 | CFItem | Abstract base class for Structured Storage entities.
 | CFItemNotFound | Raised when a named stream or a storage object are not found in a parent storage.
 | CFStorage | Storage entity that acts like a logic container for streams or substorages in a compound file.
 | CFStream | OLE structured storage stream Object It is contained inside a Storage object in a file-directory relationship and indexed by its name.
 | CFSVersion | Binary File Format Version. Sector size is 512 byte for version 3, 4096 for version 4
 | CompoundFile | Standard Microsoft© Compound File implementation. It is also known as OLE/COM structured storage and contains a hierarchy of storage and stream objects providing efficent storage of multiple kinds of documents in a single file. Version 3 and 4 of specifications are supported.
 | UpdateMode | Update mode of the compound file. Default is ReadOnly.
 | VisitedEntryAction | Action to apply to visited items in the OLE structured storage
Open MCDF

Send comments on this topic to ironfede@users.sourceforge.net

Copyright 2010 - 2011 © Federico Blaseotto


CFDisposedException Class

CFDisposedException Class
Namespaces ► OpenMcdf ► CFDisposedException
Open MCDF
Raised when a data setter/getter method is invoked on a stream or storage object after the disposal of the owner compound file object.
Declaration Syntax
C# Visual Basic Visual C++
[SerializableAttribute]
public class CFDisposedException : CFException
<SerializableAttribute> _
Public Class CFDisposedException _
    Inherits CFException
[SerializableAttribute]
public ref class CFDisposedException : public CFException
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CFDisposedException()()() | Initializes a new instance of the CFDisposedException class
 | CFDisposedException(String) | Initializes a new instance of the CFDisposedException class
 | CFDisposedException(String, Exception) | Initializes a new instance of the CFDisposedException class
 | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetBaseException()()() | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.)
 | GetType()()() | Gets the runtime type of the current instance. (Inherited from Exception.)
 | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
 | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.)
 | Message | Gets a message that describes the current exception. (Inherited from Exception.)
 | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
 | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
 | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.)
 | ToString()()() | Creates and returns a string representation of the current exception. (Inherited from Exception.)
Inheritance Hierarchy
Object
 | Exception
 |  | CFException
 |  |  | CFDisposedException

Open MCDF

Send comments on this topic to ironfede@users.sourceforge.net

Copyright 2010 - 2011 © Federico Blaseotto

Assembly: OpenMcdf (Module: OpenMcdf) Version: 1.5.1.24550


CFDisposedException Constructor

CFDisposedException Constructor
Namespaces ► OpenMcdf ► CFDisposedException ► CFDisposedException()()()
Open MCDF
Members
Icon | Member | Description
 | CFDisposedException()()() | Initializes a new instance of the CFDisposedException class
 | CFDisposedException(String) | Initializes a new instance of the CFDisposedException class
 | CFDisposedException(String, Exception) | Initializes a new instance of the CFDisposedException class


CFDisposedException Constructor

CFDisposedException Constructor
Namespaces ► OpenMcdf ► CFDisposedException ► CFDisposedException()()()
Open MCDF
Initializes a new instance of the CFDisposedException class
Declaration Syntax
C# Visual Basic Visual C++
public CFDisposedException()
Public Sub New
public:
CFDisposedException()


CFDisposedException Constructor (message)

CFDisposedException Constructor (message)
Namespaces ► OpenMcdf ► CFDisposedException ► CFDisposedException(String)
Open MCDF
Initializes a new instance of the CFDisposedException class
Declaration Syntax
C# Visual Basic Visual C++
public CFDisposedException(
    string message
)
Public Sub New ( _
    message As String _
)
public:
CFDisposedException(
    String^ message
)
Parameters
message (String)


CFDisposedException Constructor (message, innerException)

CFDisposedException Constructor (message, innerException)
Namespaces ► OpenMcdf ► CFDisposedException ► CFDisposedException(String, Exception)
Open MCDF
Initializes a new instance of the CFDisposedException class
Declaration Syntax
C# Visual Basic Visual C++
public CFDisposedException(
    string message,
    Exception innerException
)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
public:
CFDisposedException(
    String^ message,
    Exception^ innerException
)
Parameters
message (String)
innerException (Exception)


CFDuplicatedItemException Class

CFDuplicatedItemException Class
Namespaces ► OpenMcdf ► CFDuplicatedItemException
Open MCDF
Raised when trying to add a duplicated CFItem
Declaration Syntax
C# Visual Basic Visual C++
[SerializableAttribute]
public class CFDuplicatedItemException : CFException
<SerializableAttribute> _
Public Class CFDuplicatedItemException _
    Inherits CFException
[SerializableAttribute]
public ref class CFDuplicatedItemException : public CFException
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CFDuplicatedItemException()()() | Initializes a new instance of the CFDuplicatedItemException class
 | CFDuplicatedItemException(String) | Initializes a new instance of the CFDuplicatedItemException class
 | CFDuplicatedItemException(String, Exception) | Initializes a new instance of the CFDuplicatedItemException class
 | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetBaseException()()() | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.)
 | GetType()()() | Gets the runtime type of the current instance. (Inherited from Exception.)
 | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
 | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.)
 | Message | Gets a message that describes the current exception. (Inherited from Exception.)
 | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
 | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
 | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.)
 | ToString()()() | Creates and returns a string representation of the current exception. (Inherited from Exception.)
Remarks
Items are compared by name as indicated by specs. Two items with the same name CANNOT be added within a storage or sub-storage,
Inheritance Hierarchy
Object
 | Exception
 |  | CFException
 |  |  | CFDuplicatedItemException


CFDuplicatedItemException Constructor

CFDuplicatedItemException Constructor
Namespaces ► OpenMcdf ► CFDuplicatedItemException ► CFDuplicatedItemException()()()
Open MCDF
Members
Icon | Member | Description
 | CFDuplicatedItemException()()() | Initializes a new instance of the CFDuplicatedItemException class
 | CFDuplicatedItemException(String) | Initializes a new instance of the CFDuplicatedItemException class
 | CFDuplicatedItemException(String, Exception) | Initializes a new instance of the CFDuplicatedItemException class


CFDuplicatedItemException Constructor

CFDuplicatedItemException Constructor
Namespaces ► OpenMcdf ► CFDuplicatedItemException ► CFDuplicatedItemException()()()
Open MCDF
Initializes a new instance of the CFDuplicatedItemException class
Declaration Syntax
C# Visual Basic Visual C++
public CFDuplicatedItemException()
Public Sub New
public:
CFDuplicatedItemException()


CFDuplicatedItemException Constructor (message)

CFDuplicatedItemException Constructor (message)
Namespaces ► OpenMcdf ► CFDuplicatedItemException ► CFDuplicatedItemException(String)
Open MCDF
Initializes a new instance of the CFDuplicatedItemException class
Declaration Syntax
C# Visual Basic Visual C++
public CFDuplicatedItemException(
    string message
)
Public Sub New ( _
    message As String _
)
public:
CFDuplicatedItemException(
    String^ message
)
Parameters
message (String)


CFDuplicatedItemException Constructor (message, innerException)

CFDuplicatedItemException Constructor (message, innerException)
Namespaces ► OpenMcdf ► CFDuplicatedItemException ► CFDuplicatedItemException(String, Exception)
Open MCDF
Initializes a new instance of the CFDuplicatedItemException class
Declaration Syntax
C# Visual Basic Visual C++
public CFDuplicatedItemException(
    string message,
    Exception innerException
)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
public:
CFDuplicatedItemException(
    String^ message,
    Exception^ innerException
)
Parameters
message (String)
innerException (Exception)


CFException Class

CFException Class
Namespaces ► OpenMcdf ► CFException
Open MCDF
OpenMCDF base exception.
Declaration Syntax
C# Visual Basic Visual C++
[SerializableAttribute]
public class CFException : Exception
<SerializableAttribute> _
Public Class CFException _
    Inherits Exception
[SerializableAttribute]
public ref class CFException : public Exception
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CFException()()() | Initializes a new instance of the CFException class
 | CFException(String) | Initializes a new instance of the CFException class
 | CFException(String, Exception) | Initializes a new instance of the CFException class
 | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetBaseException()()() | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.)
 | GetType()()() | Gets the runtime type of the current instance. (Inherited from Exception.)
 | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
 | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.)
 | Message | Gets a message that describes the current exception. (Inherited from Exception.)
 | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
 | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
 | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.)
 | ToString()()() | Creates and returns a string representation of the current exception. (Inherited from Exception.)
Inheritance Hierarchy
Object
 | Exception
 |  | CFException
 |  |  | CFDisposedException
 |  |  | CFDuplicatedItemException
 |  |  | CFFileFormatException
 |  |  | CFInvalidOperation
 |  |  | CFItemNotFound


CFException Constructor

CFException Constructor
Namespaces ► OpenMcdf ► CFException ► CFException()()()
Open MCDF
Members
Icon | Member | Description
 | CFException()()() | Initializes a new instance of the CFException class
 | CFException(String) | Initializes a new instance of the CFException class
 | CFException(String, Exception) | Initializes a new instance of the CFException class


CFException Constructor

CFException Constructor
Namespaces ► OpenMcdf ► CFException ► CFException()()()
Open MCDF
Initializes a new instance of the CFException class
Declaration Syntax
C# Visual Basic Visual C++
public CFException()
Public Sub New
public:
CFException()


CFException Constructor (message)

CFException Constructor (message)
Namespaces ► OpenMcdf ► CFException ► CFException(String)
Open MCDF
Initializes a new instance of the CFException class
Declaration Syntax
C# Visual Basic Visual C++
public CFException(
    string message
)
Public Sub New ( _
    message As String _
)
public:
CFException(
    String^ message
)
Parameters
message (String)


CFException Constructor (message, innerException)

CFException Constructor (message, innerException)
Namespaces ► OpenMcdf ► CFException ► CFException(String, Exception)
Open MCDF
Initializes a new instance of the CFException class
Declaration Syntax
C# Visual Basic Visual C++
public CFException(
    string message,
    Exception innerException
)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
public:
CFException(
    String^ message,
    Exception^ innerException
)
Parameters
message (String)
innerException (Exception)


CFFileFormatException Class

CFFileFormatException Class
Namespaces ► OpenMcdf ► CFFileFormatException
Open MCDF
Raised when opening a file with invalid header or not supported COM/OLE Structured storage version.
Declaration Syntax
C# Visual Basic Visual C++
[SerializableAttribute]
public class CFFileFormatException : CFException
<SerializableAttribute> _
Public Class CFFileFormatException _
    Inherits CFException
[SerializableAttribute]
public ref class CFFileFormatException : public CFException
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CFFileFormatException()()() | Initializes a new instance of the CFFileFormatException class
 | CFFileFormatException(String) | Initializes a new instance of the CFFileFormatException class
 | CFFileFormatException(String, Exception) | Initializes a new instance of the CFFileFormatException class
 | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetBaseException()()() | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.)
 | GetType()()() | Gets the runtime type of the current instance. (Inherited from Exception.)
 | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
 | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.)
 | Message | Gets a message that describes the current exception. (Inherited from Exception.)
 | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
 | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
 | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.)
 | ToString()()() | Creates and returns a string representation of the current exception. (Inherited from Exception.)
Inheritance Hierarchy
Object
 | Exception
 |  | CFException
 |  |  | CFFileFormatException


CFFileFormatException Constructor

CFFileFormatException Constructor
Namespaces ► OpenMcdf ► CFFileFormatException ► CFFileFormatException()()()
Open MCDF
Members
Icon | Member | Description
 | CFFileFormatException()()() | Initializes a new instance of the CFFileFormatException class
 | CFFileFormatException(String) | Initializes a new instance of the CFFileFormatException class
 | CFFileFormatException(String, Exception) | Initializes a new instance of the CFFileFormatException class


CFFileFormatException Constructor

CFFileFormatException Constructor
Namespaces ► OpenMcdf ► CFFileFormatException ► CFFileFormatException()()()
Open MCDF
Initializes a new instance of the CFFileFormatException class
Declaration Syntax
C# Visual Basic Visual C++
public CFFileFormatException()
Public Sub New
public:
CFFileFormatException()


CFFileFormatException Constructor (message)

CFFileFormatException Constructor (message)
Namespaces ► OpenMcdf ► CFFileFormatException ► CFFileFormatException(String)
Open MCDF
Initializes a new instance of the CFFileFormatException class
Declaration Syntax
C# Visual Basic Visual C++
public CFFileFormatException(
    string message
)
Public Sub New ( _
    message As String _
)
public:
CFFileFormatException(
    String^ message
)
Parameters
message (String)


CFFileFormatException Constructor (message, innerException)

CFFileFormatException Constructor (message, innerException)
Namespaces ► OpenMcdf ► CFFileFormatException ► CFFileFormatException(String, Exception)
Open MCDF
Initializes a new instance of the CFFileFormatException class
Declaration Syntax
C# Visual Basic Visual C++
public CFFileFormatException(
    string message,
    Exception innerException
)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
public:
CFFileFormatException(
    String^ message,
    Exception^ innerException
)
Parameters
message (String)
innerException (Exception)


CFInvalidOperation Class

CFInvalidOperation Class
Namespaces ► OpenMcdf ► CFInvalidOperation
Open MCDF
Raised when a method call is invalid for the current object state
Declaration Syntax
C# Visual Basic Visual C++
[SerializableAttribute]
public class CFInvalidOperation : CFException
<SerializableAttribute> _
Public Class CFInvalidOperation _
    Inherits CFException
[SerializableAttribute]
public ref class CFInvalidOperation : public CFException
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CFInvalidOperation()()() | Initializes a new instance of the CFInvalidOperation class
 | CFInvalidOperation(String) | Initializes a new instance of the CFInvalidOperation class
 | CFInvalidOperation(String, Exception) | Initializes a new instance of the CFInvalidOperation class
 | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetBaseException()()() | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.)
 | GetType()()() | Gets the runtime type of the current instance. (Inherited from Exception.)
 | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
 | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.)
 | Message | Gets a message that describes the current exception. (Inherited from Exception.)
 | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
 | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
 | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.)
 | ToString()()() | Creates and returns a string representation of the current exception. (Inherited from Exception.)
Inheritance Hierarchy
Object
 | Exception
 |  | CFException
 |  |  | CFInvalidOperation


CFInvalidOperation Constructor

CFInvalidOperation Constructor
Namespaces ► OpenMcdf ► CFInvalidOperation ► CFInvalidOperation()()()
Open MCDF
Members
Icon | Member | Description
 | CFInvalidOperation()()() | Initializes a new instance of the CFInvalidOperation class
 | CFInvalidOperation(String) | Initializes a new instance of the CFInvalidOperation class
 | CFInvalidOperation(String, Exception) | Initializes a new instance of the CFInvalidOperation class


CFInvalidOperation Constructor

CFInvalidOperation Constructor
Namespaces ► OpenMcdf ► CFInvalidOperation ► CFInvalidOperation()()()
Open MCDF
Initializes a new instance of the CFInvalidOperation class
Declaration Syntax
C# Visual Basic Visual C++
public CFInvalidOperation()
Public Sub New
public:
CFInvalidOperation()


CFInvalidOperation Constructor (message)

CFInvalidOperation Constructor (message)
Namespaces ► OpenMcdf ► CFInvalidOperation ► CFInvalidOperation(String)
Open MCDF
Initializes a new instance of the CFInvalidOperation class
Declaration Syntax
C# Visual Basic Visual C++
public CFInvalidOperation(
    string message
)
Public Sub New ( _
    message As String _
)
public:
CFInvalidOperation(
    String^ message
)
Parameters
message (String)


CFInvalidOperation Constructor (message, innerException)

CFInvalidOperation Constructor (message, innerException)
Namespaces ► OpenMcdf ► CFInvalidOperation ► CFInvalidOperation(String, Exception)
Open MCDF
Initializes a new instance of the CFInvalidOperation class
Declaration Syntax
C# Visual Basic Visual C++
public CFInvalidOperation(
    string message,
    Exception innerException
)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
public:
CFInvalidOperation(
    String^ message,
    Exception^ innerException
)
Parameters
message (String)
innerException (Exception)


CFItem Class

CFItem Class
Namespaces ► OpenMcdf ► CFItem
Open MCDF
Abstract base class for Structured Storage entities.
Declaration Syntax
C# Visual Basic Visual C++
public abstract class CFItem : IComparable
Public MustInherit Class CFItem _
    Implements IComparable
public ref class CFItem abstract : IComparable
Members
All Members | Methods | Properties
Public Protected |  | Instance Static | Declared Inherited
Icon | Member | Description
 | CLSID | Get/Set Object class Guid for Root and Storage entries.
 | CompareTo(Object) |
 | CreationDate | Get/Set the Creation Date of the current item
 | Equality(CFItem, CFItem) |
 | Equals(Object) | (Overrides Object.Equals(Object).)
 | GetHashCode()()() | (Overrides Object.GetHashCode()()().)
 | GetType()()() | Gets the Type of the current instance. (Inherited from Object.)
 | Inequality(CFItem, CFItem) |
 | IsRoot | Return true if item is the Root Storage
 | IsStorage | Return true if item is Storage
 | IsStream | Return true if item is a Stream
 | ModifyDate | Get/Set the Modify Date of the current item
 | Name | Get entity name
 | Size | Size in bytes of the item. It has a valid value only if entity is a stream, otherwise it is setted to zero.
 | ToString()()() | Returns a String that represents the current Object. (Inherited from Object.)
Examples
CopyC#
const String STORAGE_NAME = "report.xls";
CompoundFile cf = new CompoundFile(STORAGE_NAME);

FileStream output = new FileStream("LogEntries.txt", FileMode.Create);
TextWriter tw = new StreamWriter(output);

// CFItem represents both storage and stream items
VisitedEntryAction va = delegate(CFItem item)
{
     tw.WriteLine(item.Name);
};

cf.RootStorage.VisitEntries(va, true);

tw.Close();
Inheritance Hierarchy
Object
 | CFItem
 |  | CFStorage
 |  | CFStream


CLSID Property

CLSID Property
Namespaces ► OpenMcdf ► CFItem ► CLSID
Open MCDF
Get/Set Object class Guid for Root and Storage entries.
Declaration Syntax
C# Visual Basic Visual C++
public Guid CLSID { get; set; }
Public Property CLSID As Guid
public:
property Guid CLSID {
    Guid get ();
    void set (Guid value);
}


CompareTo Method (obj)

CompareTo Method (obj)
Namespaces ► OpenMcdf ► CFItem ► CompareTo(Object)
Open MCDF

[Missing <summary> documentation for "M:OpenMcdf.CFItem.CompareTo(System.Object)"]

Declaration Syntax
C# Visual Basic Visual C++
public int CompareTo(
    Object obj
)
Public Function CompareTo ( _
    obj As Object _
) As Integer
public:
virtual int CompareTo(
    Object^ obj
) sealed
Parameters
obj (Object)


CreationDate Property

CreationDate Property
Namespaces ► OpenMcdf ► CFItem ► CreationDate
Open MCDF
Get/Set the Creation Date of the current item
Declaration Syntax
C# Visual Basic Visual C++
public DateTime CreationDate { get; set; }
Public Property CreationDate As DateTime
public:
property DateTime CreationDate {
    DateTime get ();
    void set (DateTime value);
}


Equality Operator

Equality Operator
Namespaces ► OpenMcdf ► CFItem ► Equality(CFItem, CFItem)
Open MCDF

[Missing <summary> documentation for "M:OpenMcdf.CFItem.op_Equality(OpenMcdf.CFItem,OpenMcdf.CFItem)"]

Declaration Syntax
C# Visual Basic Visual C++
public static bool operator ==(
    CFItem leftItem,
    CFItem rightItem
)
Public Shared Operator = ( _
    leftItem As CFItem, _
    rightItem As CFItem _
) As Boolean
public:
static bool operator ==(
    CFItem^ leftItem,
    CFItem^ rightItem
)
Parameters
leftItem (CFItem)
rightItem (CFItem)


Equals Method (obj)

Equals Method (obj)
Namespaces ► OpenMcdf ► CFItem ► Equals(Object)
Open MCDF

[Missing <summary> documentation for "M:OpenMcdf.CFItem.Equals(System.Object)"]

Declaration Syntax
C# Visual Basic Visual C++
public override bool Equals(
    Object obj
)
Public Overrides Function Equals ( _
    obj As Object _
) As Boolean
public:
virtual bool Equals(
    Object^ obj
) override
Parameters
obj (Object)


GetHashCode Method

GetHashCode Method
Namespaces ► OpenMcdf ► CFItem ► GetHashCode()()()
Open MCDF

[Missing <summary> documentation for "M:OpenMcdf.CFItem.GetHashCode"]

Declaration Syntax
C# Visual Basic Visual C++
public override int GetHashCode()
Public Overrides Function GetHashCode As Integer
public:
virtual int GetHashCode() override


Inequality Operator

Inequality Operator
Namespaces ► OpenMcdf ► CFItem ► Inequality(CFItem, CFItem)
Open MCDF

[Missing <summary> documentation for "M:OpenMcdf.CFItem.op_Inequality(OpenMcdf.CFItem,OpenMcdf.CFItem)"]

Declaration Syntax
C# Visual Basic Visual C++
public static bool operator !=(
    CFItem leftItem,
    CFItem rightItem
)
Public Shared Operator <> ( _
    leftItem As CFItem, _
    rightItem As CFItem _
) As Boolean
public:
static bool operator !=(
    CFItem^ leftItem,
    CFItem^ rightItem
)
Parameters
leftItem (CFItem)
rightItem (CFItem)


IsRoot Property

IsRoot Property
Namespaces ► OpenMcdf ► CFItem ► IsRoot
Open MCDF
Return true if item is the Root Storage
Declaration Syntax
C# Visual Basic Visual C++
public bool IsRoot { get; }
Public ReadOnly Property IsRoot As Boolean
public:
property bool IsRoot {
    bool get ();
}
Remarks
This check doesn't use reflection or runtime type information and doesn't suffer related performance penalties.


IsStorage Property

IsStorage Property
Namespaces ► OpenMcdf ► CFItem ► IsStorage
Open MCDF
Return true if item is Storage
Declaration Syntax
C# Visual Basic Visual C++
public bool IsStorage { get; }
Public ReadOnly Property IsStorage As Boolean
public:
property bool IsStorage {
    bool get ();
}
Remarks
This check doesn't use reflection or runtime type information and doesn't suffer related performance penalties.


IsStream Property

IsStream Property
Namespaces ► OpenMcdf ► CFItem ► IsStream
Open MCDF
Return true if item is a Stream
Declaration Syntax
C# Visual Basic Visual C++
public bool IsStream { get; }
Public ReadOnly Property IsStream As Boolean
public:
property bool IsStream {
    bool get ();
}
Remarks
This check doesn't use reflection or runtime type information and doesn't suffer related performance penalties.


ModifyDate Property

ModifyDate Property
Namespaces ► OpenMcdf ► CFItem ► ModifyDate
Open MCDF
Get/Set the Modify Date of the current item
Declaration Syntax
C# Visual Basic Visual C++
public DateTime ModifyDate { get; set; }
Public Property ModifyDate As DateTime
public:
property DateTime ModifyDate {
    DateTime get ();
    void set (DateTime value);
}


Name Property

Name Property
Namespaces ► OpenMcdf ► CFItem ► Name
Open MCDF
Get entity name
Declaration Syntax
C# Visual Basic Visual C++
public string Name { get; }
Public ReadOnly Property Name As String
public:
property String^ Name {
    String^ get ();
}


Size Property

Size Property
Namespaces ► OpenMcdf ► CFItem ► Size
Open MCDF
Size in bytes of the item. It has a valid value only if entity is a stream, otherwise it is setted to zero.
Declaration Syntax
C# Visual Basic Visual C++
public long Size { get; }
Public ReadOnly Property Size As Long
public:
property long long Size {
    long long get ();
}


CFItemNotFound Class

CFItemNotFound Class
Namespaces ► OpenMcdf ► CFItemNotFound
Open MCDF
Raised when a named stream or a storage object are not found in a parent storage.
Declaration Syntax
C# Visual Basic Visual C++
[SerializableAttribute]
public class CFItemNotFound : CFException
<SerializableAttribute> _
Public Class CFItemNotFound _
    Inherits CFException
[SerializableAttribute]
public ref class CFItemNotFound : public CFException
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CFItemNotFound()()() | Initializes a new instance of the CFItemNotFound class
 | CFItemNotFound(String) | Initializes a new instance of the CFItemNotFound class
 | CFItemNotFound(String, Exception) | Initializes a new instance of the CFItemNotFound class
 | Data | Gets a collection of key/value pairs that provide additional user-defined information about the exception. (Inherited from Exception.)
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetBaseException()()() | When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. (Inherited from Exception.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetObjectData(SerializationInfo, StreamingContext) | When overridden in a derived class, sets the SerializationInfo with information about the exception. (Inherited from Exception.)
 | GetType()()() | Gets the runtime type of the current instance. (Inherited from Exception.)
 | HelpLink | Gets or sets a link to the help file associated with this exception. (Inherited from Exception.)
 | InnerException | Gets the Exception instance that caused the current exception. (Inherited from Exception.)
 | Message | Gets a message that describes the current exception. (Inherited from Exception.)
 | Source | Gets or sets the name of the application or the object that causes the error. (Inherited from Exception.)
 | StackTrace | Gets a string representation of the frames on the call stack at the time the current exception was thrown. (Inherited from Exception.)
 | TargetSite | Gets the method that throws the current exception. (Inherited from Exception.)
 | ToString()()() | Creates and returns a string representation of the current exception. (Inherited from Exception.)
Inheritance Hierarchy
Object
 | Exception
 |  | CFException
 |  |  | CFItemNotFound


CFItemNotFound Constructor

CFItemNotFound Constructor
Namespaces ► OpenMcdf ► CFItemNotFound ► CFItemNotFound()()()
Open MCDF
Members
Icon | Member | Description
 | CFItemNotFound()()() | Initializes a new instance of the CFItemNotFound class
 | CFItemNotFound(String) | Initializes a new instance of the CFItemNotFound class
 | CFItemNotFound(String, Exception) | Initializes a new instance of the CFItemNotFound class


CFItemNotFound Constructor

CFItemNotFound Constructor
Namespaces ► OpenMcdf ► CFItemNotFound ► CFItemNotFound()()()
Open MCDF
Initializes a new instance of the CFItemNotFound class
Declaration Syntax
C# Visual Basic Visual C++
public CFItemNotFound()
Public Sub New
public:
CFItemNotFound()


CFItemNotFound Constructor (message)

CFItemNotFound Constructor (message)
Namespaces ► OpenMcdf ► CFItemNotFound ► CFItemNotFound(String)
Open MCDF
Initializes a new instance of the CFItemNotFound class
Declaration Syntax
C# Visual Basic Visual C++
public CFItemNotFound(
    string message
)
Public Sub New ( _
    message As String _
)
public:
CFItemNotFound(
    String^ message
)
Parameters
message (String)


CFItemNotFound Constructor (message, innerException)

CFItemNotFound Constructor (message, innerException)
Namespaces ► OpenMcdf ► CFItemNotFound ► CFItemNotFound(String, Exception)
Open MCDF
Initializes a new instance of the CFItemNotFound class
Declaration Syntax
C# Visual Basic Visual C++
public CFItemNotFound(
    string message,
    Exception innerException
)
Public Sub New ( _
    message As String, _
    innerException As Exception _
)
public:
CFItemNotFound(
    String^ message,
    Exception^ innerException
)
Parameters
message (String)
innerException (Exception)


CFStorage Class

CFStorage Class
Namespaces ► OpenMcdf ► CFStorage
Open MCDF
Storage entity that acts like a logic container for streams or substorages in a compound file.
Declaration Syntax
C# Visual Basic Visual C++
public class CFStorage : CFItem
Public Class CFStorage _
    Inherits CFItem
public ref class CFStorage : public CFItem
Members
All Members | Methods | Properties
Public Protected |  | Instance Static | Declared Inherited
Icon | Member | Description
 | AddStorage(String) | Create new child storage directory inside the current storage.
 | AddStream(String) | Create a new child stream inside the current storage
 | CLSID | Get/Set Object class Guid for Root and Storage entries. (Inherited from CFItem.)
 | CompareTo(Object) | (Inherited from CFItem.)
 | CreationDate | Get/Set the Creation Date of the current item (Inherited from CFItem.)
 | Delete(String) | Remove an entry from the current storage and compound file.
 | Equals(Object) | (Inherited from CFItem.)
 | GetHashCode()()() | (Inherited from CFItem.)
 | GetStorage(String) | Get a named storage contained in the current one if existing.
 | GetStream(String) | Get a named stream contained in the current storage if existing.
 | GetType()()() | Gets the Type of the current instance. (Inherited from Object.)
 | IsRoot | Return true if item is the Root Storage (Inherited from CFItem.)
 | IsStorage | Return true if item is Storage (Inherited from CFItem.)
 | IsStream | Return true if item is a Stream (Inherited from CFItem.)
 | ModifyDate | Get/Set the Modify Date of the current item (Inherited from CFItem.)
 | Name | Get entity name (Inherited from CFItem.)
 | Size | Size in bytes of the item. It has a valid value only if entity is a stream, otherwise it is setted to zero. (Inherited from CFItem.)
 | ToString()()() | Returns a String that represents the current Object. (Inherited from Object.)
 | VisitEntries(VisitedEntryAction, Boolean) | Visit all entities contained in the storage applying a user provided action
Inheritance Hierarchy
Object
 | CFItem
 |  | CFStorage


AddStorage Method (storageName)

AddStorage Method (storageName)
Namespaces ► OpenMcdf ► CFStorage ► AddStorage(String)
Open MCDF
Create new child storage directory inside the current storage.
Declaration Syntax
C# Visual Basic Visual C++
public CFStorage AddStorage(
    string storageName
)
Public Function AddStorage ( _
    storageName As String _
) As CFStorage
public:
CFStorage^ AddStorage(
    String^ storageName
)
Parameters
storageName (String)
The new storage name
Return Value
Reference to the new storage
Examples
CopyC#
String filename = "A_NEW_COMPOUND_FILE_YOU_CAN_WRITE_TO.cfs";

CompoundFile cf = new CompoundFile();

CFStorage st = cf.RootStorage.AddStorage("MyStorage");
CFStream sm = st.AddStream("MyStream");
byte[] b = Helpers.GetBuffer(220, 0x0A);
sm.SetData(b);

cf.Save(filename);
Exceptions
Exception | Condition
CFDisposedException | Raised when adding a storage to a closed compound file
CFException | Raised when adding a storage with null or empty name


AddStream Method (streamName)

AddStream Method (streamName)
Namespaces ► OpenMcdf ► CFStorage ► AddStream(String)
Open MCDF
Create a new child stream inside the current storage
Declaration Syntax
C# Visual Basic Visual C++
public CFStream AddStream(
    string streamName
)
Public Function AddStream ( _
    streamName As String _
) As CFStream
public:
CFStream^ AddStream(
    String^ streamName
)
Parameters
streamName (String)
The new stream name
Return Value
The new stream reference
Examples
CopyC#
String filename = "A_NEW_COMPOUND_FILE_YOU_CAN_WRITE_TO.cfs";

CompoundFile cf = new CompoundFile();

CFStorage st = cf.RootStorage.AddStorage("MyStorage");
CFStream sm = st.AddStream("MyStream");
byte[] b = Helpers.GetBuffer(220, 0x0A);
sm.SetData(b);

cf.Save(filename);


Delete Method (entryName)

Delete Method (entryName)
Namespaces ► OpenMcdf ► CFStorage ► Delete(String)
Open MCDF
Remove an entry from the current storage and compound file.
Declaration Syntax
C# Visual Basic Visual C++
public void Delete(
    string entryName
)
Public Sub Delete ( _
    entryName As String _
)
public:
void Delete(
    String^ entryName
)
Parameters
entryName (String)
The name of the entry in the current storage to delete
Examples
CopyC#
cf = new CompoundFile("A_FILE_YOU_CAN_CHANGE.cfs", UpdateMode.Update, true, false);
cf.RootStorage.Delete("AStream"); // AStream item is assumed to exist.
cf.Commit(true);
cf.Close();
Exceptions
Exception | Condition
CFDisposedException | Raised if trying to delete item from a closed compound file
CFItemNotFound | Raised if item to delete is not found
CFException | Raised if trying to delete root storage


GetStorage Method (storageName)

GetStorage Method (storageName)
Namespaces ► OpenMcdf ► CFStorage ► GetStorage(String)
Open MCDF
Get a named storage contained in the current one if existing.
Declaration Syntax
C# Visual Basic Visual C++
public CFStorage GetStorage(
    string storageName
)
Public Function GetStorage ( _
    storageName As String _
) As CFStorage
public:
CFStorage^ GetStorage(
    String^ storageName
)
Parameters
storageName (String)
Name of the storage to look for
Return Value
A storage reference if existing.
Examples
CopyC#
String FILENAME = "MultipleStorage2.cfs";
CompoundFile cf = new CompoundFile(FILENAME, UpdateMode.ReadOnly, false, false);

CFStorage st = cf.RootStorage.GetStorage("MyStorage");

Assert.IsNotNull(st);
cf.Close();
Exceptions
Exception | Condition
CFDisposedException | Raised if trying to delete item from a closed compound file
CFItemNotFound | Raised if item to delete is not found


GetStream Method (streamName)

GetStream Method (streamName)
Namespaces ► OpenMcdf ► CFStorage ► GetStream(String)
Open MCDF
Get a named stream contained in the current storage if existing.
Declaration Syntax
C# Visual Basic Visual C++
public CFStream GetStream(
    string streamName
)
Public Function GetStream ( _
    streamName As String _
) As CFStream
public:
CFStream^ GetStream(
    String^ streamName
)
Parameters
streamName (String)
Name of the stream to look for
Return Value
A stream reference if existing
Examples
CopyC#
String filename = "report.xls";

CompoundFile cf = new CompoundFile(filename);
CFStream foundStream = cf.RootStorage.GetStream("Workbook");

byte[] temp = foundStream.GetData();

Assert.IsNotNull(temp);

cf.Close();
Exceptions
Exception | Condition
CFDisposedException | Raised if trying to delete item from a closed compound file
CFItemNotFound | Raised if item to delete is not found


VisitEntries Method (action, recursive)

VisitEntries Method (action, recursive)
Namespaces ► OpenMcdf ► CFStorage ► VisitEntries(VisitedEntryAction, Boolean)
Open MCDF
Visit all entities contained in the storage applying a user provided action
Declaration Syntax
C# Visual Basic Visual C++
public void VisitEntries(
    VisitedEntryAction action,
    bool recursive
)
Public Sub VisitEntries ( _
    action As VisitedEntryAction, _
    recursive As Boolean _
)
public:
void VisitEntries(
    VisitedEntryAction^ action,
    bool recursive
)
Parameters
action (VisitedEntryAction)
User action to apply to visited entities
recursive (Boolean)
Visiting recursion level. True means substorages are visited recursively, false indicates that only the direct children of this storage are visited
Examples
CopyC#
const String STORAGE_NAME = "report.xls";
CompoundFile cf = new CompoundFile(STORAGE_NAME);

FileStream output = new FileStream("LogEntries.txt", FileMode.Create);
TextWriter tw = new StreamWriter(output);

VisitedEntryAction va = delegate(CFItem item)
{
    tw.WriteLine(item.Name);
};

cf.RootStorage.VisitEntries(va, true);

tw.Close();
Exceptions
Exception | Condition
CFDisposedException | Raised when visiting items of a closed compound file


CFStream Class

CFStream Class
Namespaces ► OpenMcdf ► CFStream
Open MCDF
OLE structured storage stream Object It is contained inside a Storage object in a file-directory relationship and indexed by its name.
Declaration Syntax
C# Visual Basic Visual C++
public class CFStream : CFItem
Public Class CFStream _
    Inherits CFItem
public ref class CFStream : public CFItem
Members
All Members | Methods | Properties
Public Protected |  | Instance Static | Declared Inherited
Icon | Member | Description
 | AppendData(array<Byte>[]()[]) | Append the provided data to stream data.
 | CLSID | Get/Set Object class Guid for Root and Storage entries. (Inherited from CFItem.)
 | CompareTo(Object) | (Inherited from CFItem.)
 | CopyFrom(Stream) | Copy data from an existing stream.
 | CreationDate | Get/Set the Creation Date of the current item (Inherited from CFItem.)
 | Equals(Object) | (Inherited from CFItem.)
 | GetData()()() | Get the data associated with the stream object.
 | GetData(Int64, Int32%) | Get count bytes associated with the stream object, starting from a provided offset. When method returns, count will contain the effective count of bytes read.
 | GetHashCode()()() | (Inherited from CFItem.)
 | GetType()()() | Gets the Type of the current instance. (Inherited from Object.)
 | IsRoot | Return true if item is the Root Storage (Inherited from CFItem.)
 | IsStorage | Return true if item is Storage (Inherited from CFItem.)
 | IsStream | Return true if item is a Stream (Inherited from CFItem.)
 | ModifyDate | Get/Set the Modify Date of the current item (Inherited from CFItem.)
 | Name | Get entity name (Inherited from CFItem.)
 | SetData(array<Byte>[]()[]) | Set the data associated with the stream object.
 | Size | Size in bytes of the item. It has a valid value only if entity is a stream, otherwise it is setted to zero. (Inherited from CFItem.)
 | ToString()()() | Returns a String that represents the current Object. (Inherited from Object.)
Inheritance Hierarchy
Object
 | CFItem
 |  | CFStream


AppendData Method (data)

AppendData Method (data)
Namespaces ► OpenMcdf ► CFStream ► AppendData(array<Byte>[]()[])
Open MCDF
Append the provided data to stream data.
Declaration Syntax
C# Visual Basic Visual C++
public void AppendData(
    byte[] data
)
Public Sub AppendData ( _
    data As Byte() _
)
public:
void AppendData(
    array<unsigned char>^ data
)
Parameters
data (array< Byte >[]()[])
Data bytes to append to this stream
Remarks
This method allows user to create stream with more than 2GB of data, appending data to the end of existing ones. Large streams (>2GB) are only supported by CFS version 4. Append data can also be invoked on streams with no data in order to simplify its use inside loops.
Examples
CopyC#
byte[] b = new byte[]{0x0,0x1,0x2,0x3};
byte[] b2 = new byte[]{0x4,0x5,0x6,0x7};
CompoundFile cf = new CompoundFile();
CFStream myStream = cf.RootStorage.AddStream("MyStream");
myStream.SetData(b); // here we could also have invoked .AppendData
myStream.AppendData(b2);
cf.Save("MyLargeStreamsFile.cfs);
cf.Close();


CopyFrom Method (input)

CopyFrom Method (input)
Namespaces ► OpenMcdf ► CFStream ► CopyFrom(Stream)
Open MCDF
Copy data from an existing stream.
Declaration Syntax
C# Visual Basic Visual C++
public void CopyFrom(
    Stream input
)
Public Sub CopyFrom ( _
    input As Stream _
)
public:
void CopyFrom(
    Stream^ input
)
Parameters
input (Stream)
A stream to read from
Remarks
Input stream is NOT closed after method invocation.


GetData Method

GetData Method
Namespaces ► OpenMcdf ► CFStream ► GetData()()()
Open MCDF
Members
Icon | Member | Description
 | GetData()()() | Get the data associated with the stream object.
 | GetData(Int64, Int32%) | Get count bytes associated with the stream object, starting from a provided offset. When method returns, count will contain the effective count of bytes read.


GetData Method

GetData Method
Namespaces ► OpenMcdf ► CFStream ► GetData()()()
Open MCDF
Get the data associated with the stream object.
Declaration Syntax
C# Visual Basic Visual C++
public byte[] GetData()
Public Function GetData As Byte()
public:
array<unsigned char>^ GetData()
Return Value
Array of byte containing stream data
Examples
CopyC#
CompoundFile cf2 = new CompoundFile("AFileName.cfs");
CFStream st = cf2.RootStorage.GetStream("MyStream");
byte[] buffer = st.GetData();
Exceptions
Exception | Condition
CFDisposedException | Raised when the owner compound file has been closed.


GetData Method (offset, count)

GetData Method (offset, count)
Namespaces ► OpenMcdf ► CFStream ► GetData(Int64, Int32%)
Open MCDF
Get count bytes associated with the stream object, starting from a provided offset. When method returns, count will contain the effective count of bytes read.
Declaration Syntax
C# Visual Basic Visual C++
public byte[] GetData(
    long offset,
    ref int count
)
Public Function GetData ( _
    offset As Long, _
    ByRef count As Integer _
) As Byte()
public:
array<unsigned char>^ GetData(
    long long offset,
    int% count
)
Parameters
offset (Int64)
count ( Int32 %)
Return Value
Array of byte containing stream data
Examples
CopyC#
CompoundFile cf = new CompoundFile("AFileName.cfs");
CFStream st = cf.RootStorage.GetStream("MyStream");
int count = 8;
// The stream is supposed to have a length greater than offset + count
byte[] data = st.GetData(20, ref count);
cf.Close();
Exceptions
Exception | Condition
CFDisposedException | Raised when the owner compound file has been closed.


SetData Method (data)

SetData Method (data)
Namespaces ► OpenMcdf ► CFStream ► SetData(array<Byte>[]()[])
Open MCDF
Set the data associated with the stream object.
Declaration Syntax
C# Visual Basic Visual C++
public void SetData(
    byte[] data
)
Public Sub SetData ( _
    data As Byte() _
)
public:
void SetData(
    array<unsigned char>^ data
)
Parameters
data (array< Byte >[]()[])
Data bytes to write to this stream
Examples
CopyC#
byte[] b = new byte[]{0x0,0x1,0x2,0x3};
CompoundFile cf = new CompoundFile();
CFStream myStream = cf.RootStorage.AddStream("MyStream");
myStream.SetData(b);


CFSVersion Enumeration

CFSVersion Enumeration
Namespaces ► OpenMcdf ► CFSVersion
Open MCDF
Binary File Format Version. Sector size is 512 byte for version 3, 4096 for version 4
Declaration Syntax
C# Visual Basic Visual C++
public enum CFSVersion
Public Enumeration CFSVersion
public enum class CFSVersion
Members
Member | Description
Ver_3 | Compound file version 3 - The default and most common version available. Sector size 512 bytes, 2GB max file size.
Ver_4 | Compound file version 4 - Sector size is 4096 bytes.


CompoundFile Class

CompoundFile Class
Namespaces ► OpenMcdf ► CompoundFile
Open MCDF
Standard Microsoft© Compound File implementation. It is also known as OLE/COM structured storage and contains a hierarchy of storage and stream objects providing efficent storage of multiple kinds of documents in a single file. Version 3 and 4 of specifications are supported.
Declaration Syntax
C# Visual Basic Visual C++
public class CompoundFile : IDisposable
Public Class CompoundFile _
    Implements IDisposable
public ref class CompoundFile : IDisposable
Members
All Members | Constructors | Methods | Properties
Public Protected |  | Instance Static |  | Declared Inherited
Icon | Member | Description
 | CompoundFile()()() | Create a blank, version 3 compound file. Sector recycle is turned off to achieve the best reading/writing performance in most common scenarios.
 | CompoundFile(CFSVersion, Boolean, Boolean) | Create a new, blank, compound file.
 | CompoundFile(String) | Load an existing compound file.
 | CompoundFile(String, UpdateMode, Boolean, Boolean) | Load an existing compound file.
 | CompoundFile(Stream, UpdateMode, Boolean, Boolean) | Load an existing compound file.
 | CompoundFile(Stream) | Load an existing compound file from a stream.
 | Close()()() | Close the Compound File object CompoundFile and free all associated resources (e.g. open file handle and allocated memory). Remarks When the Close method is called, all the associated stream and storage objects are invalidated: any operation invoked on them will produce a CFDisposedException.
 | Commit()()() | Commit data changes since the previously commit operation to the underlying supporting stream or file on the disk.
 | Commit(Boolean) | Commit data changes since the previously commit operation to the underlying supporting stream or file on the disk.
 | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
 | GetHashCode()()() | Serves as a hash function for a particular type. (Inherited from Object.)
 | GetType()()() | Gets the Type of the current instance. (Inherited from Object.)
 | HasSourceStream | Return true if this compound file has been loaded from an existing file or stream
 | RootStorage | The entry point object that represents the root of the structures tree to get or set storage or stream data.
 | Save(String) | Saves the in-memory image of Compound File to a file.
 | Save(Stream) | Saves the in-memory image of Compound File to a stream.
 | ShrinkCompoundFile(Stream) | Compress free space by removing unallocated sectors from compound file effectively reducing stream or file size.
 | ShrinkCompoundFile(String) | Remove unallocated sectors from compound file in order to reduce its size.
 | ToString()()() | Returns a String that represents the current Object. (Inherited from Object.)
Inheritance Hierarchy
Object
CompoundFile


CompoundFile Constructor

CompoundFile Constructor
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile()()()
Open MCDF
Members
Icon | Member | Description
 | CompoundFile()()() | Create a blank, version 3 compound file. Sector recycle is turned off to achieve the best reading/writing performance in most common scenarios.
 | CompoundFile(CFSVersion, Boolean, Boolean) | Create a new, blank, compound file.
 | CompoundFile(String) | Load an existing compound file.
 | CompoundFile(String, UpdateMode, Boolean, Boolean) | Load an existing compound file.
 | CompoundFile(Stream, UpdateMode, Boolean, Boolean) | Load an existing compound file.
 | CompoundFile(Stream) | Load an existing compound file from a stream.


CompoundFile Constructor

CompoundFile Constructor
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile()()()
Open MCDF
Create a blank, version 3 compound file. Sector recycle is turned off to achieve the best reading/writing performance in most common scenarios.
Declaration Syntax
C# Visual Basic Visual C++
public CompoundFile()
Public Sub New
public:
CompoundFile()
Examples
CopyC#
byte[] b = new byte[10000];
for (int i = 0; i < 10000; i++)
{
    b[i % 120] = (byte)i;
}

CompoundFile cf = new CompoundFile();
CFStream myStream = cf.RootStorage.AddStream("MyStream");

Assert.IsNotNull(myStream);
myStream.SetData(b);
cf.Save("MyCompoundFile.cfs");
cf.Close();


CompoundFile Constructor (cfsVersion, sectorRecycle, eraseFreeSectors)

CompoundFile Constructor (cfsVersion, sectorRecycle, eraseFreeSectors)
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile(CFSVersion, Boolean, Boolean)
Open MCDF
Create a new, blank, compound file.
Declaration Syntax
C# Visual Basic Visual C++
public CompoundFile(
    CFSVersion cfsVersion,
    bool sectorRecycle,
    bool eraseFreeSectors
)
Public Sub New ( _
    cfsVersion As CFSVersion, _
    sectorRecycle As Boolean, _
    eraseFreeSectors As Boolean _
)
public:
CompoundFile(
    CFSVersion cfsVersion,
    bool sectorRecycle,
    bool eraseFreeSectors
)
Parameters
cfsVersion (CFSVersion)
Use a specific Compound File Version to set 512 or 4096 bytes sectors
sectorRecycle (Boolean)
If true, recycle unused sectors
eraseFreeSectors (Boolean)
If true, unallocated sectors will be overwritten with zeros
Remarks
Sector recycling reduces data writing performances but avoids space wasting in scenarios with frequently data manipulation of the same streams. The new compound file is open in Update mode.
Examples
CopyC#
byte[] b = new byte[10000];
for (int i = 0; i < 10000; i++)
{
    b[i % 120] = (byte)i;
}

CompoundFile cf = new CompoundFile(CFSVersion.Ver_4, true, true);
CFStream myStream = cf.RootStorage.AddStream("MyStream");

Assert.IsNotNull(myStream);
myStream.SetData(b);
cf.Save("MyCompoundFile.cfs");
cf.Close();


CompoundFile Constructor (stream)

CompoundFile Constructor (stream)
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile(Stream)
Open MCDF
Load an existing compound file from a stream.
Declaration Syntax
C# Visual Basic Visual C++
public CompoundFile(
    Stream stream
)
Public Sub New ( _
    stream As Stream _
)
public:
CompoundFile(
    Stream^ stream
)
Parameters
stream (Stream)
Streamed compound file
Examples
CopyC#
String filename = "reportREAD.xls";

FileStream fs = new FileStream(filename, FileMode.Open);
CompoundFile cf = new CompoundFile(fs);
CFStream foundStream = cf.RootStorage.GetStream("Workbook");

byte[] temp = foundStream.GetData();

Assert.IsNotNull(temp);

cf.Close();
Exceptions
Exception | Condition
CFException | Raised when trying to open a non-seekable stream
CFException | Raised stream is null


CompoundFile Constructor (stream, updateMode, sectorRecycle, eraseFreeSectors)

CompoundFile Constructor (stream, updateMode, sectorRecycle, eraseFreeSectors)
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile(Stream, UpdateMode, Boolean, Boolean)
Open MCDF
Load an existing compound file.
Declaration Syntax
C# Visual Basic Visual C++
public CompoundFile(
    Stream stream,
    UpdateMode updateMode,
    bool sectorRecycle,
    bool eraseFreeSectors
)
Public Sub New ( _
    stream As Stream, _
    updateMode As UpdateMode, _
    sectorRecycle As Boolean, _
    eraseFreeSectors As Boolean _
)
public:
CompoundFile(
    Stream^ stream,
    UpdateMode updateMode,
    bool sectorRecycle,
    bool eraseFreeSectors
)
Parameters
stream (Stream)
A stream containing a compound file to read
updateMode (UpdateMode)
Select the update mode of the underlying data file
sectorRecycle (Boolean)
If true, recycle unused sectors
eraseFreeSectors (Boolean)
If true, overwrite with zeros unallocated sectors
Examples
CopyC#
String filename = "reportREAD.xls";

FileStream fs = new FileStream(filename, FileMode.Open);
CompoundFile cf = new CompoundFile(fs, UpdateMode.ReadOnly, false, false);
CFStream foundStream = cf.RootStorage.GetStream("Workbook");

byte[] temp = foundStream.GetData();

Assert.IsNotNull(temp);

cf.Close();
Exceptions
Exception | Condition
CFException | Raised when trying to open a non-seekable stream
CFException | Raised stream is null


CompoundFile Constructor (fileName)

CompoundFile Constructor (fileName)
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile(String)
Open MCDF
Load an existing compound file.
Declaration Syntax
C# Visual Basic Visual C++
public CompoundFile(
    string fileName
)
Public Sub New ( _
    fileName As String _
)
public:
CompoundFile(
    String^ fileName
)
Parameters
fileName (String)
Compound file to read from
Remarks
File will be open in read-only mode: it has to be saved with a different filename. A wrapping implementation has to be provided in order to remove/substitute an existing file. Version will be automatically recognized from the file. Sector recycle is turned off to achieve the best reading/writing performance in most common scenarios.
Examples
CopyC#
//A xls file should have a Workbook stream
String filename = "report.xls";

CompoundFile cf = new CompoundFile(filename);
CFStream foundStream = cf.RootStorage.GetStream("Workbook");

byte[] temp = foundStream.GetData();

Assert.IsNotNull(temp);

cf.Close();


CompoundFile Constructor (fileName, updateMode, sectorRecycle, eraseFreeSectors)

CompoundFile Constructor (fileName, updateMode, sectorRecycle, eraseFreeSectors)
Namespaces ► OpenMcdf ► CompoundFile ► CompoundFile(String, UpdateMode, Boolean, Boolean)
Open MCDF
Load an existing compound file.
Declaration Syntax
C# Visual Basic Visual C++
public CompoundFile(
    string fileName,
    UpdateMode updateMode,
    bool sectorRecycle,
    bool eraseFreeSectors
)
Public Sub New ( _
    fileName As String, _
    updateMode As UpdateMode, _
    sectorRecycle As Boolean, _
    eraseFreeSectors As Boolean _
)
public:
CompoundFile(
    String^ fileName,
    UpdateMode updateMode,
    bool sectorRecycle,
    bool eraseFreeSectors
)
Parameters
fileName (String)
Compound file to read from
updateMode (UpdateMode)
Select the update mode of the underlying data file
sectorRecycle (Boolean)
If true, recycle unused sectors
eraseFreeSectors (Boolean)
If true, overwrite with zeros unallocated sectors
Examples
CopyC#
String srcFilename = "data_YOU_CAN_CHANGE.xls";

CompoundFile cf = new CompoundFile(srcFilename, UpdateMode.Update, true, true);

Random r = new Random();

byte[] buffer = GetBuffer(r.Next(3, 4095), 0x0A);

cf.RootStorage.AddStream("MyStream").SetData(buffer);

//This will persist data to the underlying media.
cf.Commit();
cf.Close();


Close Method

Close Method
Namespaces ► OpenMcdf ► CompoundFile ► Close()()()
Open MCDF
Close the Compound File object CompoundFile and free all associated resources (e.g. open file handle and allocated memory).
Remarks
When the Close method is called, all the associated stream and storage objects are invalidated: any operation invoked on them will produce a CFDisposedException.
Declaration Syntax
C# Visual Basic Visual C++
public void Close()
Public Sub Close
public:
void Close()
Examples
CopyC#
const String FILENAME = "CompoundFile.cfs";
CompoundFile cf = new CompoundFile(FILENAME);

CFStorage st = cf.RootStorage.GetStorage("MyStorage");
cf.Close();

try
{
    byte[] temp = st.GetStream("MyStream").GetData();

    // The following line will fail because back-end object has been closed
    Assert.Fail("Stream without media");
}
catch (Exception ex)
{
    Assert.IsTrue(ex is CFDisposedException);
}


Commit Method

Commit Method
Namespaces ► OpenMcdf ► CompoundFile ► Commit()()()
Open MCDF
Members
Icon | Member | Description
 | Commit()()() | Commit data changes since the previously commit operation to the underlying supporting stream or file on the disk.
 | Commit(Boolean) | Commit data changes since the previously commit operation to the underlying supporting stream or file on the disk.


Commit Method

Commit Method
Namespaces ► OpenMcdf ► CompoundFile ► Commit()()()
Open MCDF
Commit data changes since the previously commit operation to the underlying supporting stream or file on the disk.
Declaration Syntax
C# Visual Basic Visual C++
public void Commit()
Public Sub Commit
public:
void Commit()
Remarks
This method can be used only if the supporting stream has been opened in Update mode.


Commit Method (releaseMemory)

Commit Method (releaseMemory)
Namespaces ► OpenMcdf ► CompoundFile ► Commit(Boolean)
Open MCDF
Commit data changes since the previously commit operation to the underlying supporting stream or file on the disk.
Declaration Syntax
C# Visual Basic Visual C++
public void Commit(
    bool releaseMemory
)
Public Sub Commit ( _
    releaseMemory As Boolean _
)
public:
void Commit(
    bool releaseMemory
)
Parameters
releaseMemory (Boolean)
If true, release loaded sectors to limit memory usage but reduces following read operations performance
Remarks
This method can be used only if the supporting stream has been opened in Update mode.


HasSourceStream Property

HasSourceStream Property
Namespaces ► OpenMcdf ► CompoundFile ► HasSourceStream
Open MCDF
Return true if this compound file has been loaded from an existing file or stream
Declaration Syntax
C# Visual Basic Visual C++
public bool HasSourceStream { get; }
Public ReadOnly Property HasSourceStream As Boolean
public:
property bool HasSourceStream {
    bool get ();
}


RootStorage Property

RootStorage Property
Namespaces ► OpenMcdf ► CompoundFile ► RootStorage
Open MCDF
The entry point object that represents the root of the structures tree to get or set storage or stream data.
Declaration Syntax
C# Visual Basic Visual C++
public CFStorage RootStorage { get; }
Public ReadOnly Property RootStorage As CFStorage
public:
property CFStorage^ RootStorage {
    CFStorage^ get ();
}
Examples
CopyC#
//Create a compound file
string FILENAME = "MyFileName.cfs";
CompoundFile ncf = new CompoundFile();

CFStorage l1 = ncf.RootStorage.AddStorage("Storage Level 1");

l1.AddStream("l1ns1");
l1.AddStream("l1ns2");
l1.AddStream("l1ns3");
CFStorage l2 = l1.AddStorage("Storage Level 2");
l2.AddStream("l2ns1");
l2.AddStream("l2ns2");

ncf.Save(FILENAME);
ncf.Close();


Save Method

Save Method
Namespaces ► OpenMcdf ► CompoundFile ► Save()()()
Open MCDF
Members
Icon | Member | Description
 | Save(String) | Saves the in-memory image of Compound File to a file.
 | Save(Stream) | Saves the in-memory image of Compound File to a stream.


Save Method (stream)

Save Method (stream)
Namespaces ► OpenMcdf ► CompoundFile ► Save(Stream)
Open MCDF
Saves the in-memory image of Compound File to a stream.
Declaration Syntax
C# Visual Basic Visual C++
public void Save(
    Stream stream
)
Public Sub Save ( _
    stream As Stream _
)
public:
void Save(
    Stream^ stream
)
Parameters
stream (Stream)
The stream to save compound File to
Remarks
Destination Stream must be seekable.
Examples
CopyC#
MemoryStream ms = new MemoryStream(size);

CompoundFile cf = new CompoundFile();
CFStorage st = cf.RootStorage.AddStorage("MyStorage");
CFStream sm = st.AddStream("MyStream");

byte[] b = new byte[]{0x00,0x01,0x02,0x03};

sm.SetData(b);
cf.Save(ms);
cf.Close();
Exceptions
Exception | Condition
CFException | Raised if destination stream is not seekable
CFDisposedException | Raised if Compound File Storage has been already disposed


Save Method (fileName)

Save Method (fileName)
Namespaces ► OpenMcdf ► CompoundFile ► Save(String)
Open MCDF
Saves the in-memory image of Compound File to a file.
Declaration Syntax
C# Visual Basic Visual C++
public void Save(
    string fileName
)
Public Sub Save ( _
    fileName As String _
)
public:
void Save(
    String^ fileName
)
Parameters
fileName (String)
File name to write the compound file to
Exceptions
Exception | Condition
CFException | Raised if destination file is not seekable


ShrinkCompoundFile Method

ShrinkCompoundFile Method
Namespaces ► OpenMcdf ► CompoundFile ► ShrinkCompoundFile()()()
Open MCDF
Members
Icon | Member | Description
 | ShrinkCompoundFile(Stream) | Compress free space by removing unallocated sectors from compound file effectively reducing stream or file size.
 | ShrinkCompoundFile(String) | Remove unallocated sectors from compound file in order to reduce its size.


ShrinkCompoundFile Method (s)

ShrinkCompoundFile Method (s)
Namespaces ► OpenMcdf ► CompoundFile ► ShrinkCompoundFile(Stream)
Open MCDF
Compress free space by removing unallocated sectors from compound file effectively reducing stream or file size.
Declaration Syntax
C# Visual Basic Visual C++
public static void ShrinkCompoundFile(
    Stream s
)
Public Shared Sub ShrinkCompoundFile ( _
    s As Stream _
)
public:
static void ShrinkCompoundFile(
    Stream^ s
)
Parameters
s (Stream)
Remarks
Current implementation supports compression only for ver. 3 compound files.
Examples
CopyC#
//This code has been extracted from unit test

  String FILENAME = "MultipleStorage3.cfs";

  FileInfo srcFile = new FileInfo(FILENAME);

  File.Copy(FILENAME, "MultipleStorage_Deleted_Compress.cfs", true);

  CompoundFile cf = new CompoundFile("MultipleStorage_Deleted_Compress.cfs", UpdateMode.Update, true, true);

  CFStorage st = cf.RootStorage.GetStorage("MyStorage");
  st = st.GetStorage("AnotherStorage");

  Assert.IsNotNull(st);
  st.Delete("Another2Stream"); //17Kb
  cf.Commit();
  cf.Close();

  CompoundFile.ShrinkCompoundFile("MultipleStorage_Deleted_Compress.cfs");

  FileInfo dstFile = new FileInfo("MultipleStorage_Deleted_Compress.cfs");

  Assert.IsTrue(srcFile.Length > dstFile.Length);


ShrinkCompoundFile Method (fileName)

ShrinkCompoundFile Method (fileName)
Namespaces ► OpenMcdf ► CompoundFile ► ShrinkCompoundFile(String)
Open MCDF
Remove unallocated sectors from compound file in order to reduce its size.
Declaration Syntax
C# Visual Basic Visual C++
public static void ShrinkCompoundFile(
    string fileName
)
Public Shared Sub ShrinkCompoundFile ( _
    fileName As String _
)
public:
static void ShrinkCompoundFile(
    String^ fileName
)
Parameters
fileName (String)
Remarks
Current implementation supports compression only for ver. 3 compound files.
Examples
CopyC#
//This code has been extracted from unit test

  String FILENAME = "MultipleStorage3.cfs";

  FileInfo srcFile = new FileInfo(FILENAME);

  File.Copy(FILENAME, "MultipleStorage_Deleted_Compress.cfs", true);

  CompoundFile cf = new CompoundFile("MultipleStorage_Deleted_Compress.cfs", UpdateMode.Update, true, true);

  CFStorage st = cf.RootStorage.GetStorage("MyStorage");
  st = st.GetStorage("AnotherStorage");

  Assert.IsNotNull(st);
  st.Delete("Another2Stream"); //17Kb
  cf.Commit();
  cf.Close();

  CompoundFile.ShrinkCompoundFile("MultipleStorage_Deleted_Compress.cfs");

  FileInfo dstFile = new FileInfo("MultipleStorage_Deleted_Compress.cfs");

  Assert.IsTrue(srcFile.Length > dstFile.Length);


UpdateMode Enumeration

UpdateMode Enumeration
Namespaces ► OpenMcdf ► UpdateMode
Open MCDF
Update mode of the compound file. Default is ReadOnly.
Declaration Syntax
C# Visual Basic Visual C++
public enum UpdateMode
Public Enumeration UpdateMode
public enum class UpdateMode
Members
Member | Description
ReadOnly | ReadOnly update mode prevents overwriting of the opened file. Data changes are allowed but they have to be persisted on a different file when required.
Update | Update mode allows subsequent data changing operations to be persisted directly on the opened file or stream using the Commit method when required. Warning: this option may cause existing data loss if misused.


VisitedEntryAction Delegate

VisitedEntryAction Delegate
Namespaces ► OpenMcdf ► VisitedEntryAction
Open MCDF
Action to apply to visited items in the OLE structured storage
Declaration Syntax
C# Visual Basic Visual C++
public delegate void VisitedEntryAction(
    CFItem item
)
Public Delegate Sub VisitedEntryAction ( _
    item As CFItem _
)
public delegate void VisitedEntryAction(
    CFItem^ item
)
Parameters
item (CFItem)
Currently visited item
Examples
CopyC#
//We assume that xls file should be a valid OLE compound file
const String STORAGE_NAME = "report.xls";
CompoundFile cf = new CompoundFile(STORAGE_NAME);

FileStream output = new FileStream("LogEntries.txt", FileMode.Create);
TextWriter tw = new StreamWriter(output);

VisitedEntryAction va = delegate(CFItem item)
{
    tw.WriteLine(item.Name);
};

cf.RootStorage.VisitEntries(va, true);

tw.Close();