So I am trying to create a mass media editor which allows the user to update the properties of media file types. I am using the ShellFile API pack from Microsoft.
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
So I am able to use the ShellFile class to edit metadata properties such as Rating, Tags, Title, Application Name, etc.
I am running into an issue with fields that end up having multiple items (such as Tags, Authors, Artists) because they are of the type:
public ShellProperty<string[]> Author { get; }
So for example say that you have multiple items.
If you try to update these outside of the properties window through code, say something like:
ShellFile shellFile = ShellFile.FromFilePath(((Media)mediaFile).FilePath);
if (mediaFile is Picture)
{
String[] authorArray = ((Picture)mediaFile).Authors.Split(',');
shellFile.Properties.System.Author.Value = authorArray;
/*** Writing other values to mediaFile ***/
}
This leads into you getting this error if you try to add more authors/tags/whatever to a file:
System.ArgumentOutOfRangeException: 'A value had to be truncated in a string or rounded if a numeric value. Set AllowTruncatedValue to true to prevent this exception. Parameter name: value'
I'm wondering if there is a way to get around this? Since it's a property of the API and Arrays are immutable & I can't actually make it larger, or use something more friendly like a List <String>
. I tried Array.Resize
however I didn't have any luck with it.