FileOpenPicker: Access is denied on first app run


  • On the first run of the application, when it tries to call fileOpenPicker.pickMultipleFilesAsync(), it will cause an "Access is denied" exception.

    After restarting the app, everything works as expected. This is a new issue in the Release Candidate and was previously working in the Consumer Preview build (tested it on two machines) but I couldn't find anything related in the migration notes.

    All the best

    Edit: I just found that if I add a WinJS.Promise.timeout(500) before that, it works - any ideas?
    Wednesday, June 6, 2012 9:11 AM

All replies

  • We need more details Marcus.

    Where are you calling this in your code and when?

    Jeff Sanders (MSFT)

    Wednesday, June 6, 2012 2:16 PM
  • Hi Jeff,

    there's a call to Windows.UI.Popups.MessageDialog.showAsync, one of the UICommands then goes on to do this:

    fileOpenPicker = new FileOpenPicker();
    fileOpenPicker.commitButtonText = translatedText;
    fileOpenPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
    return WinJS.Promise.timeout(100).then(function() {
      try {
        return fileOpenPicker.pickMultipleFilesAsync().then(function(fileList) {

    The timeout(100) is my workaround, calling pickMultipleFilesAsync() immediately will make it crash. I also tried using msSetImmediate but that doesn't seem to be enough.

    Friday, June 8, 2012 8:03 AM