0
votes

Why am I getting an error in this code?

 StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
 StorageFile sampleFile = await folder.CreateFileAsync("sample.jpg", CreationCollisionOption.ReplaceExisting);

Error:

Additional information: Acces denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

In Windows store app and how to fix this problem?

1

1 Answers

2
votes

You should not (or cannot) use app installed location to create files because it is read-only.

If you want to create app files you should use another directory like:

StorageFolder folder = ApplicationData.Current.LocalFolder: