locked
How to use StgOpenStorageEx with a file picked with the Picker?

    Question

  • Can StgOpenStorageEx be used on files the user picked with the picker?
    Sunday, February 26, 2012 5:37 PM

Answers

  • Hi Phil,

    No, you cannot use StgOpenStorageEx for files picked with the FilePicker. Your app does not access to the file, only to the data within the file. 

    As Han says, StgOpenStorageEx (along with other Win32 API) can access only the locations natively accessible to the app: files and folders within the app's local storage and install dir.

    The app doesn't have direct access to files outside of those areas and cannot use API which try to directly access them.

    The app has brokered access to other files via the FilePicker, Capabilities, etc. These locations are not read directly by the app but go through a broker process which reads the files and provides a stream to the data via the StorageFile WinRT classes.

    Using files: accessing, searching, and acting on files should give more details on how this works.

    --Rob

    Monday, February 27, 2012 4:43 PM
    Owner

All replies

  • Yes, StgOpenStorageEx can be called in the Metro style application. But you should make sure that the file you access lies in the application local storage.

    See: Windows.Storage.ApplicationData (http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata(v=VS.85).aspx)

    Best Regards,

    Han Xia

    Monday, February 27, 2012 2:46 PM
    Moderator
  • Thanks for your reply. But as I wrote, I would like to know if I can use StgOpenStorageEx for files the user picked using the filepicker. I would assume since the user picked the file via Picker I have full access to it?
    Monday, February 27, 2012 3:04 PM
  • Hi Phil,

    No, you cannot use StgOpenStorageEx for files picked with the FilePicker. Your app does not access to the file, only to the data within the file. 

    As Han says, StgOpenStorageEx (along with other Win32 API) can access only the locations natively accessible to the app: files and folders within the app's local storage and install dir.

    The app doesn't have direct access to files outside of those areas and cannot use API which try to directly access them.

    The app has brokered access to other files via the FilePicker, Capabilities, etc. These locations are not read directly by the app but go through a broker process which reads the files and provides a stream to the data via the StorageFile WinRT classes.

    Using files: accessing, searching, and acting on files should give more details on how this works.

    --Rob

    Monday, February 27, 2012 4:43 PM
    Owner