Answered by:
Right Access Issues When Using Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFolderAsync

Question
-
Let me start off by saying I'm Universal Windows naïve to the highest degree. I understand and have used C# primarily for web apps so be gentle. So, I'm trying out this tutorial while learning universal apps: http://www.c-sharpcorner.com/UploadFile/99bb20/metro-style-app/
and I can get it all working fine, but when it trys to create the local EMP folder it fails to -
An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.ni.dll but was not handled in user codeAdditional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
So, thinking this is a simple as hades question, but I'll be darned if I can't find that many references for how to fix it.
I'm really enjoying learning Windows Universal App development. Making the move from c# code behind web apps using .net has been relatively easy considering the similar code behind modeling.
My Visual Studio 2015 Info:
Microsoft Visual Studio Community 2015
Version 14.0.24720.00 Update 1
Microsoft .NET Framework
Version 4.6.01038Any help you can provide on what I have to imagine is a simple question above is appreciated.
Answers
-
Of course, within minutes of writing the above I find the answer in the comments to the original tutorial! DOH!
but if it helps anyone. this set of lines work as a replacement.
Windows.Storage.StorageFolder sf = await ApplicationData.Current.LocalFolder.CreateFolderAsync("EMP", CreationCollisionOption.OpenIfExists);
StorageFile st = await sf.CreateFileAsync("Employee.xml", CreationCollisionOption.OpenIfExists);
await dom.SaveToFileAsync(st);
- Marked as answer by Murdock_SE Saturday, February 13, 2016 1:46 PM
All replies
-
Of course, within minutes of writing the above I find the answer in the comments to the original tutorial! DOH!
but if it helps anyone. this set of lines work as a replacement.
Windows.Storage.StorageFolder sf = await ApplicationData.Current.LocalFolder.CreateFolderAsync("EMP", CreationCollisionOption.OpenIfExists);
StorageFile st = await sf.CreateFileAsync("Employee.xml", CreationCollisionOption.OpenIfExists);
await dom.SaveToFileAsync(st);
- Marked as answer by Murdock_SE Saturday, February 13, 2016 1:46 PM
-