Introduction
I am trying to make a compression application. The current obstacle I am facing is that whenever I try to compress my file I take a byte array from the file and apply compression algorithm on the byte array itself because of which the metadata of file is lost.
Question
Is there any method by which I can extract the metadata of a file on compression and later on extraction attach the metadata to the extracted file?
Visual Studio : VS2008
Framework : .Net 3.5
Solutions I found:
- I have seen in many articles that they say we can use Windows Property System but even after reading the article I have no clue as to how can I implement it.
- This website has explained with the code but they didn't give any download link for the DLL.
- From this Stackoverflow answer I got this code:-
//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();
I get the following error on Line 8
The name is not valid. (Exception from HRESULT: 0x800300FC (STG_E_INVALIDNAME))