How to Read the Properties of files using IpropertyStorage?

后端 未结 1 1715
生来不讨喜
生来不讨喜 2021-01-23 03:10

how to read the properties(Like title,author,Page count etc.,) of files using iPropertyStorage? anyone know the code in c# please post it

Actually,

I\'m trying

相关标签:
1条回答
  • 2021-01-23 04:00

    Shell programming like this is invariably hard to do. You'll have a fighting chance on this one though, shell32.dll has an automation interface that's callable from COM clients. The ShellFolderItem::ExtendedProperty property makes them available. You'll need a WPF or Windows Forms project so that COM is properly initialized. Use Project + Add Reference, Browse tab, select c:\windows\system32\shell32.dll. This sample code reads the Author property of the c:\temp\test.txt file:

      Shell32.Shell shl = new Shell32.ShellClass();
      Shell32.Folder dir = shl.NameSpace(@"c:\temp");
      Shell32.FolderItem itm = dir.Items().Item("test.txt");
      Shell32.ShellFolderItem itm2 = (Shell32.ShellFolderItem)itm;
      string prop = (string)itm2.ExtendedProperty("{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 4");
      Console.WriteLine(prop);
    

    The property ID (PID) values that you can use are documented in this SDK article.

    0 讨论(0)
提交回复
热议问题