I got Access is denied when trying to CreateFileAsync in InstalledLocation StorageFolder
StorageFolder storageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile file = await storageFolder.CreateFileAsync("fileNmae", Windows.Storage.CreationCollisionOption.ReplaceExisting);
Also I tried
var storageFolder = await StorageFolder.GetFolderFromPathAsync("ms-appx:///");
And got “value does not fall within the expected range”
I can go around and CreateFileAsync in Windows.Storage.ApplicationData.Current.LocalFolder then CopyAsync to InstalledLocation StorageFolder?
StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile file = await storageFolder.CreateFileAsync("fileName", Windows.Storage.CreationCollisionOption.ReplaceExisting);
StorageFolder installedLocationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
var result = await file.CopyAsync(installedLocationFolder, "fileName", Windows.Storage.NameCollisionOption.ReplaceExisting);
but CreateFileAsync in InstalledLocation StorageFolder gives Access denied ?
is that because of security reason or I’m coding something wrong here?
The app’s install directory is a read-only location. In addition, it would not be recommended that you write data files to the installed location. If you need to store data this is for the application’s use only, you should use
or
depending on the lifetime of the data.