Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:22:25+00:00 2026-06-13T12:22:25+00:00

Problem accessing mp3 files in WinRT app. ‘System.UnauthorizedAccessException’ occurs when app tries to open

  • 0

Problem accessing mp3 files in WinRT app.

‘System.UnauthorizedAccessException’ occurs when app tries to open a mp3 file by name in the same folder as a file returned by FileOpenPicker. Put another way, the user picks an info file in Documents with the same name as a mp3 file. App opens the info file just fine but cannot open the mp3 file.

For example: I have a pair of files (file1.info) and (file1.mp3). A filepicker allows selecting a (*.info) file.

The user selects (file1.info). The app then opens both (file1.info) and (file1.mp3). Both files reside in a DocumentsLibrary folder, but are NOT in the MusicLibrary. The problem is when I try to open (file1.mp3) I get the ‘UnauthorizedAccessException’.

To prepro the issue:

Files:
Copy an mp3 file to Documents.
Create a text file with the same base name as the mp3 file and change its extension to .info.

In Package.appxmanifest > Declarations add a ‘File Type Associations’ declaration. Check ‘Open is safe’. Add

supported file types ‘.mp3’ and ‘.info’. Leave ‘Content type’ empty.

Code:

Dim file as StorageFile
Dim fileopenpicker As FileOpenPicker
Dim infofile As StorageFile
Dim mp3file As StorageFile 
Dim filename As String
fileopenpicker = New FileOpenPicker()
fileopenpicker.FileTypeFilter.Add(".info")
fileopenpicker.FileTypeFilter.Add(".mp3")
fileopenpicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary
file = Await fileopenpicker.PickSingleFileAsync()
If file.Path.EndsWith(".info") Then
    infofile = file
    filename = file.Path.Substring(0, file.Path.Length - 4) & "mp3"
    ' This command fails with 'System.UnauthorizedAccessException'
    mp3file = Await StorageFile.GetFileFromPathAsync(filename)
Else 'file is an mp3 file
    mp3file = file
    filename = file.Path.Substring(0, file.Path.Length - 3) & "info"
    ' This command succeeds!
    infofile = Await StorageFile.GetFileFromPathAsync(filename)
End If

So it appears that there is some specific problem with opening an mp3 file when the file is not actually chosen by the fileopenpicker.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:22:26+00:00Added an answer on June 13, 2026 at 12:22 pm

    I checked this issue with an app that has the capability Documents Library and the filetypes .mp3 and .info declared. I figured out that it seems to be a very strange bug. If you pass the path to the documents library folder using an uppercase drive letter after having opened a FileOpenPicker you get an UnauthorizedAccessException. Using the path with a lowercase drive letter works. Strangely you can use an uppercase drive letter before having opened a FileOpenPicker.

    So the workaround is to lowercase the path.

    Here’s the code I used (C#):

    // Trying to get some files from the documents library
    // Note: F:\Program Data is my primary documents library folder
    string mp3FilePath = @"F:\Program Data\2Mann1Maus.mp3";
    
    // This works even if the drive letter is uppercase
    StorageFile file1 = await StorageFile.GetFileFromPathAsync(mp3FilePath);
    
    // It also works with a lowercase drive letter
    string infoFilePath = @"f:\Program Data\2Mann1Maus.info";
    StorageFile file2 = await StorageFile.GetFileFromPathAsync(infoFilePath);
    
    FileOpenPicker fileopenpicker = new FileOpenPicker();
    fileopenpicker.FileTypeFilter.Add(".info");
    fileopenpicker.FileTypeFilter.Add(".mp3");
    fileopenpicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    StorageFile file = await fileopenpicker.PickSingleFileAsync();
    if (file.Path.EndsWith(".info"))
    {
       string filename = file.Path.Substring(0, file.Path.Length - 4) + "mp3";   
    
       // This works
       string testFileName1 = filename.Substring(0, 1).ToLower() + 
          filename.Substring(1,  filename.Length - 1);
       StorageFile mp3file1 = await StorageFile.GetFileFromPathAsync(testFileName1);
    
       // This works as well
       string testFileName2 = filename.ToLower();
       StorageFile mp3file2 = await StorageFile.GetFileFromPathAsync(testFileName2); 
    
       // This does cause an UnauthorizedAccessException
       StorageFile mp3file3 = await StorageFile.GetFileFromPathAsync(filename);
    }
    else
    {
       StorageFile mp3file = file;
       String filename = file.Path.Substring(0, file.Path.Length - 3) + "info"; 
    
       // This works
       string testFileName1 = filename.Substring(0, 1).ToLower() + 
          filename.Substring(1, filename.Length - 1);
       StorageFile infoFile1 = await StorageFile.GetFileFromPathAsync(testFileName1); 
    
       // This works as well
       string testFileName2 = filename.ToLower();
       StorageFile infoFile2 = await StorageFile.GetFileFromPathAsync(testFileName2); 
    
       // This does cause an UnauthorizedAccessException
       StorageFile infoFile3 = await StorageFile.GetFileFromPathAsync(filename);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i`m writing simple metro style app in c#. Now i have problem accessing files
I am building my first ASP.Net MVC based app and have a problem accessing
I have just noticed a problem accessing a CSS file using forms authentication from
I am using this http://nunzioweb.com/streaming_audio-example.htm to embed and play.mp3 files The problem is that
I am having a problem accessing a static const variable defined in my class
I am having a problem accessing the @attribute section of my SimpleXML object. When
I am having a problem accessing the ViewData object through javascript. I have set
I have a problem accessing JSON data. I'm new to JSON and jquery so
I'm having a problem accessing an object defined in the root package. If I
I'am having problem in accessing json array elements. Below is the response when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.