【发布时间】:2018-09-26 13:04:26
【问题描述】:
简介
我正在尝试制作一个压缩应用程序。我目前面临的障碍是,每当我尝试压缩文件时,我都会从文件中获取一个字节数组,并对字节数组本身应用压缩算法,因此 文件的元数据会丢失。
问题
有什么方法可以在压缩时提取文件的元数据,然后在提取时将元数据附加到提取的文件中?
Visual Studio : VS2008
框架:.Net 3.5
我找到的解决方案:
- 我在很多文章中看到他们说我们可以使用Windows Property System,但即使在阅读了这篇文章后,我也不知道如何实现它。
- This 网站已经解释了代码,但他们没有给出 DLL 的任何下载链接。
- 从这个Stackoverflow answer我得到了这个代码:-
//creates new class of oledocumentproperties var doc = new OleDocumentPropertiesClass(); //open your selected file doc.Open(@"C:\Users\ABC\Desktop\Test\1.jpg", false, dsoFileOpenOptions.dsoOptionDefault); //you can set properties with summaryproperties.nameOfProperty = value; for example doc.SummaryProperties.Company = "lol"; //Line 8 : Shows error doc.SummaryProperties.Author = "me"; //after making changes, you need to use this line to save them doc.Save();
我在 第 8 行
收到以下错误名称无效。 (来自 HRESULT 的异常:0x800300FC (STG_E_INVALIDNAME))
【问题讨论】: