I’m trying to launch a save dialog in my windows RT app when someone tries to close a file which has not been saved. However, I keep getting a 0x80070005 - JavaScript runtime error: Access is denied error
This is the code I’m using the launch the message dialog. When “Don’t Save” is chosen (and BlankFile() is run) everything runs ok. However when you choose “Save File” it throws the access denied error when it tries to run .pickSaveFileAsync()
function createNewFile()
{
if (editedSinceSave)
{
// Create the message dialog and set its content
var msg = new Windows.UI.Popups.MessageDialog("Save this file?",
"Save Changes");
// Add commands
msg.commands.append(new Windows.UI.Popups.UICommand("Don't Save",
function (command) {
BlankFile();
}));
msg.commands.append(new Windows.UI.Popups.UICommand("Save File",
function (command) {
//saveFile(true, true);
testPop("test");
}));
// Set the command that will be invoked by default
msg.defaultCommandIndex = 2;
// Show the message dialog
msg.showAsync();
}
}
function testPop(text) {
var msg = new Windows.UI.Popups.MessageDialog(text, "");
msg.showAsync();
}
Your core problem is you are tying to show a message dialog ontop of another. I discuss the details, and the solution here:
What is the alternative to `alert` in metro apps?
However, you flow naturally needs this is to happen — I suggest looking at building a different type of flow rather than stacking dialogs.