Domanda

I am having a very strange error when trying to access a ".stl" file in the "Stl" folder of my application when the app is downloaded from the Windows Phone Marketplace. It does not exhibit this behavior when it is launched from Visual Studio 2012 Express in either debug or release mode. Once I try loading a file it gives me an "System.UnauthorizedAccessException Access to path 'C:\Data\Programs\APPUID\Install\Stl\test.stl' is denied" exception while accessing a ".gcode" file in an almost exactly the same fashion from the "GCode" causes no error what so ever.

I have no idea what could be causing this or how to debug this because I don't know if I can somehow attach the debugger to an instance of the store downloaded app.

I also have no idea what could possibly be different between deploying the exact same app from the store and from Visual Studio. The Visual Studio installed app also does not give any troubles if the app is launched from the phone without the debugger being attached.

Any ideas?

PS. The file is being opened by a filestream which is then used by a binarreader. I am not sure if the source code is really needed and for which part but the important line is just:

FileStream fileStream = new FileStream(filePath, FileMode.Open);

Where "filePath" in this case is "Stl\test.stl".

È stato utile?

Soluzione 2

Ok I figured it out. The "install" directory is actually restricted access but for some reason the Visual Studio signing process leaves the app with enough permissions to access this folder. The correct procedure of determining a relative directory is not to use "Directory.GetCurrentDirectory()" but rather to use "ApplicationData.Current.LocalFolder". Hope this helps!

Altri suggerimenti

Without seeing your actual code it is hard to say what the problem is. So instead of attempting to read your mind I will offer an alternative solution.

I have worked extensively with Isolated Storage on the Windows Phone and I have learned this.

There is no library, no API, no SDK, no Web service, in the world, that has worse error reporting than the Isolated Storage on windows phone.

EVERYTHING is Invalid Access or Unauthorized Access with ZERO further information.

To remedy this I created a DLL that serializes objects to the Isolated Storage for you.

All you have to do is put [DataContractAttribute] above your class name and [DataMemeber] above any variable you want saved. Then you just pass your object and unique name into the savefile method. That's it! Instant save

You can find my free DLL EZ_Iso.dll for download here. With example code and instructions

The code is open source so if you wish you may also decompile the dll and see how it all works.

Feel free to reach out to me here or on twitter if you have any questions or enhancements.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top