Accessing AppData\Local\Temp directory RRS feed

  • Question

  • I'm creating a Windows Store App under Windows 8 (not 8.1). I expected the following lines of code to return the following path:


    Instead, I get the following:


    Any thoughts on how to get what I expected?


    Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
    Windows.Storage.StorageFolder tempFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;


    Monday, October 21, 2013 2:26 PM

All replies

  • Windows Store applications are designed to run in a highly sandboxed environment. Part of this sandboxing involves isolating the access that each individual application has to the file system.

    So as a result of that design, unless the user explicitly grants the application permissions otherwise (through a filepicker dialog, etc) or has the Document Library capability, an application can only access the file system under it's install directory (which is read-only) (ex. "[System Drive]:\Program Files\WindowsApps\[PackageId]\) and it's state directory ([System Drive]:\Users\[user]\AppData\Local\Packages\[PackageId]\).

    This design provides 2 guarantees:

    • One application will not interfere with another.
    • When a user uninstalls an application, it is uninstalled cleanly and doesn't leave traces on the file system.

    So with all of that in mind, the next question becomes why do you need access to the AppData\Local\Temp folder? Knowing why will help more directly answer your question.

    Dan Rigby - http://danrigby.com

    Monday, October 21, 2013 7:03 PM
  • Many thanks for the response.

    I'm taking pieces of components designed for Windows 7. In the old system, another dll within my solution generates an xml file and places is in the AppData\Local\Temp folder. The class library I'm working on reads in the xml file and makes choices based on specific values.

    To get started debugging, I just copied the files that were generated by the Windows 7 version. The code that generates the xml file isn't work yet. Hopefully, that doesn't make any difference.



    Monday, October 21, 2013 7:31 PM