OpenMcdf 2.3.1

dotnet add package OpenMcdf --version 2.3.1
NuGet\Install-Package OpenMcdf -Version 2.3.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenMcdf" Version="2.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenMcdf --version 2.3.1
#r "nuget: OpenMcdf, 2.3.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OpenMcdf as a Cake Addin
#addin nuget:?package=OpenMcdf&version=2.3.1

// Install OpenMcdf as a Cake Tool
#tool nuget:?package=OpenMcdf&version=2.3.1

Build Status

openmcdf

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 (*.aaf files for example).

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");

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

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
cf.Close();

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

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

...as 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

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

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

CompoundFile.ShrinkCompoundFile("MultipleStorage_Deleted_Compress.cfs"); 

OLE Properties handling for DocumentSummaryInfo and SummaryInfo streams
is now available via extension methods (experimental - 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 targets netstandard 2.0 to allow maximum client compatibility AND .net framework 4 for legacy implementations.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (30)

Showing the top 5 NuGet packages that depend on OpenMcdf:

Package Downloads
MsgReader

Read Outlook MSG and EML files without using Outlook. The MSGReader supports MSG E-Mail (also signed), Contact, Appointment, Task, Sticky notes and Contact files. The EML reader supports MIME 1.0 encoded files.

FileSignatures

A small library for detecting the type of a file based on header signature (also known as magic number) rather than file extension.

MsgKit

MsgKit is a 100% managed C# .NET library (no PINVOKE or whatsoever) which may be used for the creation of messages (E-Mail, Appointments, Journals and Stickey Notes) that are Outlook compatible

mzLib

Library for mass spectrometry projects.

OpenMcdf.Extensions

Extensions for OLE Properties and IO.Stream interface for OpenMcdf (Beta)

GitHub repositories (15)

Showing the top 5 popular GitHub repositories that depend on OpenMcdf:

Repository Stars
QL-Win/QuickLook
Bring macOS “Quick Look” feature to Windows
vivami/SauronEye
Search tool to find specific files containing specific words, i.e. files containing passwords..
michaelweber/Macrome
Excel Macro Document Reader/Writer for Red Teamers & Analysts
Sicos1977/MSGReader
C# Outlook MSG file reader without the need for Outlook
freezy/VisualPinball.Engine
:video_game: Visual Pinball Engine for Unity
Version Downloads Last updated
2.3.1 98,867 3/2/2024
2.3.0 653,301 4/22/2023
2.2.1.12 488,281 8/30/2022
2.2.1.9 2,851,151 9/18/2020
2.2.1.6 57,567 7/22/2020
2.2.1.5 1,382 7/21/2020
2.2.1.4 566,838 12/7/2019
2.2.1.3 1,132,696 10/27/2018
2.2.1.2 6,633 10/6/2018
2.2.0.1 37,016 7/22/2018
2.1.6.28924 41,028 4/14/2018
2.1.5.22659 16,400 3/17/2018
2.1.4.23498 1,705 3/10/2018
2.1.3.34730 12,621 7/22/2017
2.1.3.34720 2,046 6/2/2017
2.1.2.1274 2,757 3/17/2017
2.1.0.33051 8,049 12/29/2016
2.0.5739.40493 311,233 9/18/2015
1.5.4.22637 20,113 1/24/2013

Bug fixing (high priority for #119, issue with stream resizing) and enhancements in extensions