I am attempting to us TagLib-Sharp to read metadata from mp4 videos but get an UnauthorizedAccessException. I'm using the FileOpenPicker and have made the proper declarations.
Any ideas? Thanks in advance.
Error: "An exception of type 'System.UnauthorizedAccessException' occurred in taglib-sharp.DLL but was not handled in user code
Additional information: Access to the path 'C:\Users\user\Videos\VideoName.mp4' is denied."
Code:
private async void Button_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
openPicker.FileTypeFilter.Add(".mp4");
StorageFile selection = await openPicker.PickSingleFileAsync();
var selectionstring = selection.Path.ToString();
if (selection != null)
{
//TagLib.File file = TagLib.File.Create(selectionstring); //<-Exception thrown here
//TagLib.Tag Tag = file.GetTag(TagLib.TagTypes.Id3v2);
//var frame = file.Tag.Comment.ToString();
OutputTextBlock.Text = selectionstring;
var stream = await selection.OpenAsync(Windows.Storage.FileAccessMode.Read);
videoWindow.SetSource(stream, selection.ContentType);
videoWindow.Play(); //The video will play just fine so I know I have read access.
}
else
{
OutputTextBlock.Text = "Operation cancelled.";
}
}