Reputation: 41
the situation is as follows: I want to put pictures i get to a file in my assets. I want to get the folder with:
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(Directory.GetCurrentDirectory());
and the create a file there with:
File.Create(folder.Path + @"\" + "Assets" + @"\" + storageItem.DisplayName + storageItem.FileType);
But it throws an System.UnauthorizedAccessException at me when i try to create the file. I need a permanent fix for this as other users (some without administrative powers) will need to use the program i am writing.
Thank you in advance
Upvotes: 0
Views: 130
Reputation: 124
that's correct because you can not alter or create something in installed dir only option available to this dir is reading files that exist there.
if you want to keep some file in-app local or temp directory then you can use
AppliacationData.Currunt.LocalFolder/TemproryFolder etc to keep your file
Upvotes: 1
Reputation: 787
Its likely your current directory is set to somewhere which required administrator permission. You can change your current directory:
The below looks like a fairly solid overview on where you should store things and has plenty of code examples
https://www.codeproject.com/Tips/370232/Where-should-I-store-my-data
Upvotes: 1