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!
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).
If I understand you correctly, this thread has the answer for you:
Read/Write ‘Extended’ file properties (C#)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With