locked
Access Denied When C# WinRT Component Tries to create file

    Question

  • Hello,

    I have a sample app (C++/CX Store app) that imports a C# .winmd (WinRT Component). When I import the .winmd file the import seems to go fine, the issue is when I access a method in the .winmd component. What the method does is try and create a file in the directory that the app is installed. So from my C++ store app I send a parameter to the WinRT Component method that gives the installation directory, and the .winmd WinRT component takes that directory and tries to create a file in that directory. Unfortunately when it does that I get an exception, I catch the exception and get the following error:  

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    Is there a way to allow that .winmd that I reference create a file in that location?

    Saturday, July 27, 2013 4:13 AM

Answers

  • The app install directory is read only. You cannot write a new file there. You may be able to write there if you are running the app without deploying it from VS, but in production the app will always be deployed to a directory it cannot write to.

    Instead create your files in the app data directories.

    --Rob

    Saturday, July 27, 2013 5:22 AM
    Moderator