Gets the root folder in the temporary app data store.
Syntax
var temporaryFolder = applicationData.temporaryFolder;
Property value
Type: StorageFolder
The file system folder that contains the files.
Remarks
You can access files in the temporary app data store using the "ms-appdata:///temp/" protocol. For example:
<img src="ms-appdata:///temp/myFile.png" alt="" />
Windows Phone 8
This API is not implemented and will throw an exception if called.
Examples
Use the file APIs, such as Windows.Storage.StorageFolder.CreateFileAsync | createFileAsync and Windows.Storage.FileIO.WriteTextAsync | writeTextAsync, to create and update a file in the temporary app data store. This example creates a file named dataFile.txt in the temporaryFolder container and writes the current date and time to the file. The ReplaceExisting | replaceExisting value from the CreationCollisionOption enumeration indicates that the file should be replaced if it already exists.
Next, this example opens the dataFile.txt file created and reads the date from the file using Windows.Storage.FileIO.ReadTextAsync | readTextAsync.
var applicationData = Windows.Storage.ApplicationData.current; var temporaryFolder = applicationData.temporaryFolder; // Write data to a file function writeTimestamp() { temporaryFolder.createFileAsync("dataFile.txt", Windows.Storage.CreationCollisionOption.replaceExisting) .then(function (sampleFile) { var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime"); var timestamp = formatter.format(new Date()); return Windows.Storage.FileIO.writeTextAsync(sampleFile, timestamp); }).done(function () { }); } // Read data from a file function readTimestamp() { temporaryFolder.getFileAsync("dataFile.txt") .then(function (sampleFile) { return Windows.Storage.FileIO.readTextAsync(sampleFile); }).done(function (timestamp) { // Data is contained in timestamp }, function () { // Timestamp not found }); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
|
DLL |
|
See also
- Tasks
- Quickstart: Temporary application data (JavaScript)
- Quickstart: Temporary application data (C#/VB/C++)
- Concepts
- Application data overview
- Reference
- ApplicationData
Build date: 2/25/2013