locked
Access denied on Windows.Storage.FileIO.writeTextAsync to write a text file in a local application folder RRS feed

  • Question

  • Hi Everybody, 

    I got access denied exception when calling Windows.Storage.FileIO.writeTextAsync() to write a text file in local installed app folder.

    var url = Windows.Foundation.Uri("ms-appx:///saved/config.json");

    Windows.Storage.StorageFile.getFileFromApplicationUriAsync(url).then(function (file) {
                            Windows.Storage.FileIO.writeTextAsync(file, jsonText).then(function(e) {
                                if (onSuccess)
                                    onSuccess(e);   // on success is a callback method which called when the function succeeded.
                            }, function (e) {
                                var a = e;
                            });
                        });

    I've both run on debug / release mode

    Thanks

    -Y-


    Monday, November 12, 2012 12:18 AM

Answers

All replies

  • This is expected. Apps don't have write access to their installed directory.

    You can save files in your app data folders. See Managing app data

    --Rob

    Monday, November 12, 2012 12:32 AM
    Moderator
  • Thanks Rob, I wonder because I have done with that code in CP, and it worked. but in the RTM I always get an exception 'access denied'.

    I will change my code, since I cannot use that code anymore. 

    -Y-


    Monday, November 12, 2012 4:12 AM