Getting 'An item with the same key has already been added' when trying to get extended file properties

78 Views Asked by At

I've been trying to use WindowsAPICodePack to get extended file properties but I keep running into the same problem. I'm getting 'An item with the same key has already been added' and I can't understand how and why.

public string Name = "";
public string Date = "";
public string Time = "";
public string FullPath = "";
public string FileName = "";
public int Duration = 0;
public double FrameRate = 0;
public Int64 Size = 0;
public string AMDAudioFile = "";
public string Thumbnail = "";
public string VWidth = "";
public string VHeight = "";
public string VBitrate = "";
public string ABitrate = "";

    var file = ShellFile.FromFilePath(FilePath);

    Duration = int.Parse(TimeSpan.Parse(file.Properties.System.Media.Duration.FormatForDisplay(PropertyDescriptionFormatOptions.None)).TotalSeconds.ToString());     
    Size = Int64.Parse(file.Properties.System.TotalFileSize.FormatForDisplay(PropertyDescriptionFormatOptions.None)); 
    FrameRate = double.Parse(Regex.Replace(file.Properties.System.Video.FrameRate.ValueAsObject.ToString(), @"[^\u0000-\u007F]+", string.Empty));
    VWidth = file.Properties.System.Video.FrameWidth.ValueAsObject.ToString().Trim();
    VHeight = file.Properties.System.Video.FrameHeight.ValueAsObject.ToString().Trim();
    VBitrate = file.Properties.System.Video.EncodingBitrate.ValueAsObject.ToString().Trim();
    ABitrate = Regex.Replace(file.Properties.System.Audio.EncodingBitrate.FormatForDisplay(PropertyDescriptionFormatOptions.None), @"[^\d]", "");
0

There are 0 best solutions below