locked
Access Error when my app is launched from IE or email attachment

    Question

  • My app is has a file association for audio files (mp3, m4a, etc.)

    When I attempt to open an audio attachment from Mail by using the "Open" command, my app throws and error because it does not have permission. I get the same error when launching from IE (again, using the "open" command, instead of "save).

    How can my app be successfully launched under these conditions?

    Friday, February 28, 2014 4:42 AM

Answers

  • What error do you get and where? Attach a debugger to see what is going on.

    My guess is that the app tries to open the attachment by name rather than using the StorageFile which is passed in to the app.

    The former won't work: the app doesn't have access to the file directly but needs to access it through the StorageFile object.

    --Rob

    Friday, February 28, 2014 5:44 AM

All replies

  • What error do you get and where? Attach a debugger to see what is going on.

    My guess is that the app tries to open the attachment by name rather than using the StorageFile which is passed in to the app.

    The former won't work: the app doesn't have access to the file directly but needs to access it through the StorageFile object.

    --Rob

    Friday, February 28, 2014 5:44 AM
  • I was hoping it was something simple like a declaration in the manifest, but it looks a little more complicated. It actually begins to play the file (it's an audio player) and the error happens somewhere after that.

    So I'm digging into the debugger.... this might take a minute...

    Friday, February 28, 2014 3:31 PM
  • Okay that didn't take as long as I thought :)

    My app tried to scan the folder of the launched file for more audio tracks. I had to tweak the error handler that's thrown when I don't have permission for the folder.

    Thanks for your help.

    Friday, February 28, 2014 3:43 PM
  • You can scan the folder of the launched file by looking at the FileActivatedEventArgs' NeighboringFilesQuery property
    Friday, February 28, 2014 4:38 PM
    Owner
  • It was my understanding that NeighboringFiles only applies when using file activation, but I also needed to perform the same action when using the File Picker so I wrote my own ScanFolder function using getFolderFromPath. Unless FilePicker also has a similar function I don't know about ... ??

    If not, I guess I could use a combination of the two (NeighboringFiles and my own ScanFolder) which would at least give me access to the other files when the user starts with File Activation.

    • Edited by TravisMDodd Friday, February 28, 2014 5:44 PM
    Friday, February 28, 2014 5:39 PM
  • Right. NeighboringFiles is only available for file activation.

    For the picker scenario you'll need to pick the folder and then run your own ScanFolder. Picking the file and then using getFolderFromPath will work only if the user picks a file in a library the app has access to.

    --Rob

    Saturday, March 01, 2014 1:54 AM
    Owner