Skip to content

Access To The Path is Denied #318

@shaneusername

Description

@shaneusername

Hi all, first off, many thanks for the effort you have put into creating this great library.

I'm currently working on an UWP app to get a list of all MP3s in a folder and for each of these show the various MP3 tags of the files. I'm using the folderPicker.PickSingleFolderAsync() method to select the chosen folder and query.GetFilesAsync() to store a list of the MP3 files in a StorageFile list.

Everytime TagLib.File.Create runs, I get an exception, 2147024891, Access to the path 'D:\DJ Music...' is denied. In my Package.appxmanifest, I've given my app, the full necessary permissions to access all folders.

  <Capabilities>
    <rescap:Capability Name="broadFileSystemAccess"/>    
    <uap:Capability Name="musicLibrary"/>
    <rescap:Capability Name="runFullTrust"/>
  </Capabilities>

Here's my relevant code

            if (folder != null)
            {
                mp3ids.Logging("In code to get list of MP3s in " + mp3ids.FolderPath, "high");

                List<string> fileTypeFilter = new List<string>();
                fileTypeFilter.Add(".mp3");
                var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilter);
                var query = folder.CreateFileQueryWithOptions(queryOptions);

                mp3ids.fileList = await query.GetFilesAsync();

                mp3ids.Logging("The count of MP3s in the folder is " + mp3ids.fileList.Count, "high");


                foreach (StorageFile file in mp3ids.fileList)
                {
                    mp3ids.Logging("File: " + file.Path, "high");

                    try
                    {
                        var tfile = TagLib.File.Create(file.Path, ReadStyle.Average);

                        FullListOfMP3s.Add(new ListOfMP3s { mp3filename = file.Name, mp3path = file.Path, mp3title = tfile.Tag.Title, mp3artist = tfile.Tag.Performers[0], mp3album = tfile.Tag.Album });
                    }
                    catch (UnauthorizedAccessException Ex)
                    {
                        mp3ids.Logging("Exception: " + Ex.Message, "high");
                        mp3ids.Logging("Exception HResult: " + Ex.HResult, "high");
                    }
                }
            }

Any suggestions on how to fix this? The exception is only thrown when I run taglib. Without taglib, I can access and read the files in the folders without any exception. When I publish and install the app on my desktop, I've also given it the necessary permissions to access file system but still the same result.

Thanks
Shane

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions