Code & Sundry

Jon G Stødle

Files uploaded with Device Portal gives “Access denied” at runtime

247 words, 2 minutes to read

Now here’s a nice nut to crack: I was trying to write some code to read the settings file generated by IsolatedStorageSettings in Silverlight for Windows Phone. The file is named __ApplicationSettings and if it was located, it should be loaded, read and the contents parsed.

Sounds simple enough.

I opened Device Portal which lets me see the files in the local storage of the new UWP app and also lets me upload new files. I upload a test file which contains some sample data and run the app to see if the logic works.

No such luck.

I get an UnauthorizedAccessException. And no matter how I try to read the file, it won’t let me. After trying to google around the interwebs, asking some select people and reading this excellent post by Pedro Lamas, I was getting nowhere.

It wasn’t until Rodrigo Diaz pointed out that maybe the Device Portal was the problem. I then tried using the “IsolatedStorageExplorer” tool for Windows Phone 8.1 and upload the file to the device that way.

IT WORKS!

It looks like the Device Portal uploads the files with some sort of weird permissions. I haven’t seen anyone else having this problem when searching, but I might have looked in the wrong places. The weird thing is though, the IsolatedStorageExplorer wasn’t able to read the files either, but writing went fine. Weird…