Skip to content
Microsoft Compound File .net component - pure C# - NET Standard 2.0
Branch: master
Clone or download
ironfede Merge pull request #46 from michaelp/master
Continious integration using Azure Pipe Lines
Latest commit a62d584 Apr 14, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Update index.htm Jul 30, 2017
.gitignore Set up CI with Azure Pipelines Apr 14, 2019
License.txt Refactoring of sources layout. Sep 18, 2015
MakeRelease.cmd Refactoring of sources layout. Sep 18, 2015
OpenMcdf.sln Benchmarking stream reading Apr 9, 2019
OpenMcdf.sln.DotSettings Benchmarking stream reading Apr 9, 2019
OpenMcdf.snk Added strong name to OpenMcdf #7 Jul 22, 2017 Update Nov 21, 2018
Release notes.txt Update Release notes.txt Jul 22, 2018
Support.txt Update Support.txt Dec 31, 2016
azure-pipelines.yml Set up CI with Azure Pipelines Apr 14, 2019


Structured Storage .net component - pure C#

OpenMCDF is a 100% .net / C# component that allows developers to manipulate Microsoft Compound Document Files (also known as OLE structured storage).

Compound file includes multiple streams of information (document summary, user data) in a single container.

This file format is used under the hood by a lot of applications: all the documents created by Microsoft Office until the 2007 product release are structured storage files. Windows thumbnails cache files (thumbs.db) are compound documents as well as .msg Outlook messages. Visual Studio .suo files (solution options) are compound files and a lot of audio/video editing tools save project file in a compound container.

OpenMcdf supports read/write operations on streams and storages and traversal of structures tree. It supports version 3 and 4 of the specifications, uses lazy loading wherever possible to reduce memory usage and offer an intuitive API to work with structured files.

It's very easy to create a new compound file

byte[] b = new byte[10000];

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


You can open an existing one, an excel workbook (.xls) and use its main data stream

//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();
//do something with temp

Adding storage and stream items is just as easy...

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

cf.RootStorage.Delete("AStream"); // AStream item is assumed to exist.

Call commit() method when you need to persist changes to the underlying stream


If you need to compress a compound file, you can purge its unused space


OLE Properties handling for DocumentSummaryInfo and SummaryInfo streams
is now available via extension methods (beta - api subjected to changes)

PropertySetStream mgr = ((CFStream)target).AsOLEProperties();
for (int i = 0; i < mgr.PropertySet0.NumProperties; i++)
  ITypedPropertyValue p = mgr.PropertySet0.Properties[i];

OpenMcdf runs happily on the Mono platform and supports now .NET Standard 2.0

You can’t perform that action at this time.