Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read custom file properties in c#

I'm looking for a way to read document properties in C#. I've heard about dsofile.dll, but it seems like an old COM wrapper, and was wondering if there is something more modern for the .NET framework/C#. What I'm actually reading is not an office document file, but a Solidworks .SLDDRW file, that has Custom properties. You can view and change these in Windows Explorer by right-clicking on the file, and going to the Properties window, Custom tab.

Anyone know how to read these custom properties in C# / .NET 3.5?

Thanks!

like image 646
Randy Gamage Avatar asked Jun 10 '10 17:06

Randy Gamage


2 Answers

The SolidWorks system uses the OLE Document Properties API. As you've pointed out, Microsoft offers a sample, DSOFile.dll, that allows you to access these properties:

http://support.microsoft.com/kb/224351

The SolidWorks API also has robust support for these properties, but you have to load Solidworks to use the API, so it's not always the ideal solution. Note that if the file is already open in Solidworks, however, you won't be able to edit custom properties using DSOfile.dll.

The simple answer to your question is that there isn't an updated API for these properties; much the same way many other legacy APIs (DDE, for example) continue to appear in production environments, DSOFile suits the need and honestly wouldn't be entirely appropriate for update due to its fairly low-level nature. DSOFile, however, is perfectly capable of handling your needs and it works quite cleanly with .NET. The source is available and can be compiled to 64 bit if that is an issue for your users; it does mean you need a separate 64 bit install, but that's a small price to pay (plus SolidWorks isn't exactly cross-bitness-friendly to begin with).

like image 160
Mike Burton Avatar answered Nov 15 '22 13:11

Mike Burton


If I understand you correctly, this thread has the answer for you:

Read/Write ‘Extended’ file properties (C#)

like image 26
Dirk Vollmar Avatar answered Nov 15 '22 13:11

Dirk Vollmar