Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access To The Path is Denied #318

Open
shaneusername opened this issue Jan 6, 2023 · 1 comment
Open

Access To The Path is Denied #318

shaneusername opened this issue Jan 6, 2023 · 1 comment

Comments

@shaneusername
Copy link

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

@jorgedevs
Copy link

jorgedevs commented Sep 9, 2024

Shame this issue has no updates for over a year. Just hit this today, gonna have to check other packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants