如何设置扩展文件属性? [英] How to SET extended file properties?

查看:217
本文介绍了如何设置扩展文件属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我说的,你看我已经知道如何使用shell32.dll中类,让他们性质文件属性 - >摘要(作者,标题等),我asumed,我也可以用相同的类设置他们,但似乎喜欢写扩展属性是一点点困难和shell32.dll中不允许这样做。我无法找到设置属性明确的解决方案(虽然有很多关于让他们)。
同时还发现一些关于标签库锐利,这似乎有一个选项来设置扩展属性,但我真的不明白它是如何工作的。也许有比这更好的解决方案。
如果有帮助,我需要只为公司字段设置值有些字,.pdf文档。

I am talking about properties you see in file properties->summary (Author, Title, etc) I already know how to GET them by using shell32.dll class, and I asumed that I could also SET them with the same class, but it seems like writing extended properties is a little bit more difficult and shell32.dll doesn't allow to do that. I was unable to find a clear solution for SETTING properties (though there are a lot about getting them). Also found something about taglib-sharp, which seems to have an option to SET extended properties, but I don't really understand how it works. Maybe there are better solutions than that. If it helps, I need to SET value only for Company field for some Word, .pdf documents.

推荐答案

确定这里就是答案我自己的问题,因为我是不是真的能找到我在这个论坛的答案,也可能是为别人有用。
解决方案是使用dsofile.dll和OleDocumentPropertiesClass。
下面是一些关于dsofile.dll MS文章 - 链接
在这个环节,你可以用一些其他文件下载dsofile.dll。但最有可能的,就像我一样,你将面对一些难以奇怪的问题,找到一个解决方案。

Ok here is answer to my own question, since I wasn't really able to find my answer in this forum, it could be useful for others. Solution is to use dsofile.dll and OleDocumentPropertiesClass. Here is MS article about dsofile.dll - Link In this link, you can download dsofile.dll with some other files. But most probably, just like I did, you will face some weird problems that are hard to find a solution for.

1)intalling dsofile.dll后,您需要注册类:OPED cmd并导航到C:\\ dsofile到目录中,你有你的提取下载dsofile.dll。在此之后 - 写行 REGSVR32 dsofile.dll 。你应该得到一个消息说,registeration是成功的。如果不是这样,最propably你没有管理权限。您将需要的情况下,你想要这个工作管理员权限。

1) After intalling dsofile.dll, you will need to register the class: oped cmd and navigate to c:\dsofile of to directory, where you have extracted your downloaded dsofile.dll. After that - write line regsvr32 dsofile.dll. You should get a messagebox saying that registeration was succesful. If not, most propably you don't have admin rights. You are going to need admin rights in case you want this to work.

2)尝试使用这个类在你的程序中,如果您使用的是.NET 4.0是可以的,你会看到错误,说像后的类不能被嵌入的......
那么,对于中,右键点击dsofile参考文献列表,属性 - >嵌入互操作文件 ​​- >设置为FALSE

2) After trying to use this class in your program, if you are using .NET 4.0 it is possible, that you will see error saying something like "class cannot be embedded ..." Well, for that, right click on dsofile in references list, properties -> embed interop files -> set to FALSE.

3)使用方法:

    //creates new class of oledocumentproperties
    var doc = new OleDocumentPropertiesClass();

    //open your selected file
    doc.Open(pathToFile, false, dsoFileOpenOptions.dsoOptionDefault);

    //you can set properties with summaryproperties.nameOfProperty = value; for example
    doc.SummaryProperties.Company = "lol";
    doc.SummaryProperties.Author = "me";

    //after making changes, you need to use this line to save them
    doc.Save();

这篇关于如何设置扩展文件属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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