Read a comment of the file

c#, extended-properties

Solution

The comments and other answer are good places to search. Here is some complete code to help you out. Ensure you reference `shell32.dll` first and the namespace `Shell32`. I've done this in LINQPad so it's a touch different.

Pick a test file and folder:

var folder = "...";
var file = "...";

Get the Shell objects:

// For our LINQPad Users
// var shellType = Type.GetTypeFromProgID("Shell.Application");
// dynamic app = Activator.CreateInstance(shellType);   

Shell32.Shell app = new Shell32.Shell();

Get the folder and file objects:

var folderObj = app.NameSpace(folder);
var filesObj = folderObj.Items();

Find the possible headers:

var headers = new Dictionary<string, int>();
for( int i = 0; i < short.MaxValue; i++ )
{
    string header = folderObj.GetDetailsOf(null, i);
    if (String.IsNullOrEmpty(header))
        break;
    if (!headers.ContainsKey(header)) headers.Add(header, i);
}

You can print these out if you like - that's all possible headers available in that directory. Let's use the header 'Comments' as an example:

var testFile = filesObj.Item(file);
Console.WriteLine("{0} -> {1}", testFile.Name, folderObj.GetDetailsOf(testFile, headers["Comments"]));

Modify as needed!

Problem

Some files has Summary tab in their Properties, This tab include information like Title, Author, Comments. Is there any way in C# to read the Comments of the file. I have to read only comments from image files like jpg.

Original source

Related problems