如何阅读在C#中自定义文件属性 [英] How to read custom file properties in c#

查看:405
本文介绍了如何阅读在C#中自定义文件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来读取C#文档属性。我听说过dsofile.dll,但它似乎是一个古老的COM包装,并想知道是否有更现代的东西对于.NET Framework / C#。我正在看其实不是一个办公文档文件,而是一个Solidworks的.SLDDRW文件,包含自定义属性。您可以查看并通过右键单击该文件更改这些在Windows资源管理器,将属性窗口,自定义选项卡。

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.

任何人都知道如何阅读这些自定义属性在C#/。NET 3.5?

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

谢谢!

推荐答案

的SolidWorks的系统使用OLE文档属性API。正如您所指出的那样,微软提供了一个样本,DSOFile.dll,允许你访问这些属性:

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

SolidWorks的API也有这些强大的支持属性,但你必须加载Solidworks的使用API​​,所以它并不总是理想的解决方案。请注意,如果该文件是在SolidWorks已经打开,但是,您将无法使用编辑自定义DSOfile.dll属性。

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.

简单回答你的问题是有没有为这些属性更新的API;大致相同的方式很多其他遗留的API(DDE,例如)继续出现在生产环境中,DSOFile适合的必要性,并如实不会完全适当的更新,由于其相当低的水平的性质。 DSOFile,但是,是完全有能力处理您的需求,它的工作原理很干净地.NET。提供源代码,并可以被编译成64位,如果这是你的用户的问题;它意味着你需要一个单独的64位安装,但是这是一个很小的代价(加SolidWorks是不完全的跨位数友好与开始)。

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

这篇关于如何阅读在C#中自定义文件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆