3
Я пытаюсь сохранить строку в текстовый файл в моей папке темп, но у меня есть эта ошибка:Ошибка при использовании Windows.Storage имен
Error2'await' requires that the type 'Windows.Foundation.IAsyncAction' have a
suitable GetAwaiter method. Are you missing a using directive for 'System'
Благодаря
P.S. это приложение консоли C#.
Мой код:
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
}
}
}
_using Windows.Storage_ как я должен это получить ... –