Wednesday, March 12, 2008

Structured Storage

I've been trying to figure out how to store some metadata information on file system. One way to do this, is using Structured Storage. You've probably seen this in action, if not, you can open file Properties and select the Summary (Details in Windows Vista) tab.

Unfortunately, there's no managed way to access this data in .NET environment, and there's no resource on how to call this unmanaged API in .NET, so I decided to write a wrapper around already existing API in OLE32.Dll and here it is.

There are some limitation on what you can do with this and where you can use it. Basically, this metadata is only available on NTFS file system, meaning if you manipulate this metadata on a file and move it to a FAT32 file system, all the data is lost (of course Windows will notify you about this). Furthurmore, you have Microsoft Office file formats, which have build-in metadata storage capability. The good thing is if you move a office file to a FAT32 filesystem, the already existing metadata will not perish.

So, provided class here wraps around StgOpenStorageEx method in OLE32. The StgOpenStorageEx method works with two interfaces :

  • The IPropertyStorage interface which manages the persistent properties of a single property set.
  • The IPropertySetStorage that opens, creates and deletes the property set storages that support instances of the IPropertyStorage interface.

The implementation here only reads and writes the data, but should you need a more elegant solution, e.g. deleting a set, you should have no problem finding your way out.

You can download the file here.

Updated : Use my sky drive folder to download the attachment.
Submit this story to DotNetKicks Shout it


Anonymous said...

Hi Hadi,

Could you please send me the code for the structured storage access to me at

The download link on your site does not work.

Thanks in advance


Anonymous said...

Could you please send me the code to


Anonymous said...

Could you please update the code example link? It doesn't work.

Hadi Eskandari said...


I just double checked posted URL for the download link, and it works fine. May be my web host was done the time you tried. I guess I have to host my content files somewhere else :(

Yelena said...

Good for people to know.

Anonymous said...

Nope the link is broken again. Can you upload it something like rapidshare?

Hadi Eskandari said...

Use the updated link. The file is on my Sky-Drive folder so you should have no problem downloading it.