Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using Windows.Storage;
- public static class Storage
- {
- public static async void SaveData()
- {
- string myString = "This is the data I want to save";
- ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
- // Add: using Windows.Storage;
- Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;
- // Optionally overwrite any existing file with CreationCollisionOption
- StorageFile file = await localFolder.CreateFileAsync("mySaveFile.txt", CreationCollisionOption.ReplaceExisting);
- try
- {
- if (file != null)
- {
- await FileIO.WriteTextAsync(file, myString);
- }
- }
- catch (FileNotFoundException)
- {
- // Error saving data
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement