I would like to read/write the window information file (extended file properties) using c#
The one found by doing the following: In window explorer right click => properties => Summary tab. I want mainly to have access to the properties:
- Title
- Category
- Revision Number
For office document I can use the following (using Office.Interop) or using DSOFile
private static string GetExcelWorkbookPropertyValue(_Workbook workbook, string propertyName)
{
DocumentProperties builtInProperties = (DocumentProperties)workbook.BuiltinDocumentProperties;
string value = builtInProperties.Cast<DocumentProperty>().First(x => x.Name.Equals(propertyName, StringComparison.InvariantCultureIgnoreCase)).Value;
return value ?? "";
}
But what i would like is a more general solution that will work with all files.
Could someone help?
Question additional information you can also read the properties Title and Category by using Shell32
Shell32.Shell shell = new Shell32.Shell();
//set the namespace to file path
Shell32.Folder folder = shell.NameSpace(Path.GetDirectoryName(file));
//get ahandle to the file
Shell32.FolderItem folderItem = folder.ParseName(Path.GetFileName(file));
//did we get a handle ?
if (folderItem != null)
{
for (int i = 0; i < 100; i++)
{
string s = folder.GetDetailsOf(folderItem, i);
System.Diagnostics.Debug.WriteLine(s);
}
}
However I still write the properity Revision Number, however it's look like Revision number is an office document property and cannot be written (I guess it will break the tracking process of office).
What does not make sense is that I can modify it using window explorer and the property is also visible for non-office documents... I'm struggling to understand that.