Reputation: 1621
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 to programatically (using c#) read the file properties (Title, Summary, Author, Comments etc.... The stuff that shows up on the Summary tab when you see the properties of a file).
FileInfo and FileSystemInfo classes expose only the standard properties (create time, mod time etc..) so i'm trying to use ipropertyStorage. any one know the solution post it will be helpful.
Upvotes: 2
Views: 5576
Reputation: 941635
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.
Upvotes: 2