locked
Write to the file in the InstalledLocation encounter "Access is Denied" (0x80070005)! RRS feed

  • Question

  • Hi,

    Read file in the InstalledLocation works fine, but can't write to this file.

    How to fix this problem?

    StorageFolder folder = Package.Current.InstalledLocation.
                    GetFolderAsync(@"Settings").AsTask().Result;
                StorageFile file = folder.GetFileAsync(@"Settings.json").AsTask().Result;
                string jsonString = FileIO.ReadTextAsync(file).AsTask().Result;
                var rootObject = JsonObject.Parse(jsonString);
                rootObject["set1"]= JsonValue.CreateStringValue("ok");
                FileIO.WriteTextAsync(file, rootObject.Stringify()).AsTask().Wait();


    Wednesday, April 24, 2019 11:03 AM

All replies

  • Hi,

    In you question, you are trying to write into the install directory and it gives the error. This behavior is expected. Because the app's install directory is a read-only location. This is mentioned in the document here:Application install directory. You could refer this document for more information about file access permissions.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 25, 2019 2:53 AM
  • Hi Roy,

    Thank you for your answer!

    I have added and tried with "broadFileSystemAccess" capability, but the same problem still happened: "

    Access is Denied". 

    Any ideas?

    Thursday, April 25, 2019 4:20 AM
  • Hi,

    broadFileSystemAccess capability does not help to this. As I mentioned in my last reply. This behavior is by design. So it is read-only.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 25, 2019 4:37 AM