File open fails with permission denied error(fopen()) RRS feed

  • Question

  • Hi,

    I am developing WinRT c++ component and from the component  i am trying to open a file on harddisk .

    But I got an error-permission denied.

    so how to use a harddik file from runtime component?



    Wednesday, April 18, 2012 6:18 PM


  • Hi Bhash,

    Metro style apps do not have permissions to most of the file system, only to files within their install location and application data store. You should be able to use fopen in those locations, but not elsewhere.

    You can get limited access to the various libraries (Documents, Music, Photos, etc.) by declaring the appropriate Capabilities, but that access needs to come through the StorageFolder and StorageFile classes. Since your process doesn't have permission to read these files a broker process will open them for you and provide their contents as a stream.

    The user can grant your app access to other files on the system by choosing them in a file picker. This access would also be brokered and provided via the StorageFolder and StorageFile classes.


    Wednesday, April 18, 2012 9:10 PM