- Home /
Access is denied in Windows 8 App
I am creating a Windows Store App that allows you to write and edit basic text files with the extension .note. I have written a basic script which works fine in previews, but simply wont work when I run as a Windows 8 app. The code below is raising an Access to path is denied error in the debug. (snippet from the full script)
var MyDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
path = MyDocsPath+"/TakeNote/Notes/";
Debug.Log(path);
if (!Directory.Exists(path)){
Debug.Log("Directory does not exist");
Directory.CreateDirectory(path);
}else{
Debug.Log("Directory exists");
}
I think that this code is correct (because it works in previews) and that my issue is with giving the app the correct permissions on the system, but I can't seem to find where you can add file access permission in unity or in visual studio express.
Any help would be greatly appreciated.
I wonder how you compiled it. Environment.GetFolderPath, Environment.SpecialFolder and Directory class are not supported in Windows Store applications. At least according to official Unity Windows Store FAQ.
If you open first link and go to System.IO namespace, you won't see Dictionary there. If you go to System namespace, you will see Environment class, but only the members marked with green suitcase icon (or whatever it is...) work in Windows Store apps.
Ahh! That would explain everything! Looks like I will have to re-code the entire script to work around this. Thanks for the help.