Get or set file details programmatically [duplicat

2019-05-10 16:50发布

问题:

This question already has an answer here:

  • How to get the EXIF data from a file using C# [closed] 7 answers

Try going to any file, right clicking on it, and clicking on the "Details" tab. Like this photo

I want to change this values. Also Can I add custom properties the file details. Especially I want to do this changes for tif,jpeg,png,pdf files. Can I see my custom properties in "Details" window?

I found this page but it can change only office files. http://www.microsoft.com/en-us/download/details.aspx?id=8422

回答1:

You can use the Windows API Code Pack. It has wrappers for the Windows Property System.



回答2:

Just an addition to Eli Arbels answer, an example from the documentation from the Windows API Code Pack (which works very well for us):

IShellProperty prop = ShellObject.FromParsingName(fileName).Properties.GetProperty(propertyName);

if (prop.ValueType == typeof(string))
{
    (prop as ShellProperty<string>).Value = value;
}


标签: c# file details