Quickly build Windows 8 style Apps 28-temporary app data

Source: Internet
Author: User

Original: Quick build Windows 8 style app 28-temporary app data

This post focuses on temporary app data overview and how to build temporary app data.

I. Overview of temporary application Data

Temporary app data is equivalent to caching in Web pages, which are not capable of roaming and can be deleted at any time.

Usually the system can delete these temporary application data for maintenance tasks at any time, and we can delete the data through Disk Cleanup.

In general, we store temporary information during the session, for example: QQ chat record and so on.

second, how to build temporary application data1. Declaring temporary storage objects

Use the Applicationdata.temporaryfolder property to get the file.

Windows.Storage.StorageFolder temporaryfolder = ApplicationData.Current.TemporaryFolder;
2. Write temporary data to file

Using Windows.Storage.StorageFolder.CreateFileAsync and Windows.Storage.FileIO.WriteTextAsync Create and update files in the temporary app data store.

void Writetimestamp ()
{
   
       New Windows.Globalization.DatetimeFormatting.DateTimeFormatter ("longtime");
   StorageFile Samplefile = await Temporaryfolder.createfileasync ("DataFile.txt"
       createcollisionoption.replaceexisting);
   Await Fileio.writetextasync (Samplefile, formatter. Format (DateTime.Now));
}
3. Get temporary data from the file

Use Windows.Storage.StorageFolder.GetFileAsync, Windows.Storage.StorageFile.GetFileFromApplicationUriAsync and Windows.Storage.FileIO.ReadTextAsync Open and read files in the temporary app data store.

void Readtimestamp ()
{
   Try
   {
      StorageFile Samplefile = await Temporaryfolder.getfileasync ("DataFile.txt");
      String timestamp = await fileio.readtextasync (samplefile);
   }
   Catch (Exception)
   {
   }
}

The relevant information can be consulted:

1. Application data;

2. Examples of application data;

3.Windows.Storage.ApplicationData;

4.Windows.Storage.ApplicationDataCompositeValue;

5.Windows.Storage.ApplicationDataContainer;

6.Windows.Storage.ApplicationDataContainerSettings;

Quickly build Windows 8 style Apps 28-temporary app data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.