Guest User

Untitled

a guest
Jan 15th, 2015
196
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using Windows.Storage;
  5.  
  6. public static class Storage
  7. {
  8.  
  9.     public static async void SaveData()
  10.     {
  11.         string myString = "This is the data I want to save";
  12.         ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
  13.        
  14.         // Add:  using Windows.Storage;
  15.         Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;
  16.  
  17.         // Optionally overwrite any existing file with CreationCollisionOption
  18.         StorageFile file = await localFolder.CreateFileAsync("mySaveFile.txt", CreationCollisionOption.ReplaceExisting);
  19.  
  20.         try
  21.         {
  22.             if (file != null)
  23.             {
  24.                 await FileIO.WriteTextAsync(file, myString);
  25.             }
  26.         }
  27.         catch (FileNotFoundException)
  28.         {
  29.             // Error saving data
  30.         }
  31.     }
  32.  
  33.  
  34. }
RAW Paste Data