Windows Phone CreateFolderAsync方法在等待时发出错误

时间:2013-11-08 05:27:49

标签: c# windows-phone-8

我试图了解WindowsPhone Files/Folder
正在按照msdn撰写CreateFolderAsync方法

private async Task WriteToFile()
{
 StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;    
 var dataFolder =await local.CreateFolderAsync("DataFolder", CreationCollisionOption.OpenIfExists);
 //code goes here
}

发出错误

Type Windows.Foundation.IAsyncOperation<Windows.Storage.StorageFolder> is not awaitable


当我删除await关键字时,它很好,但我没有获得dataFolder.CreateFileAsync方法 我相信我没有错过任何参考。任何人都可以告诉为什么会发生这种错误?

1 个答案:

答案 0 :(得分:0)

在等待之前尝试将其转换为任务

await local.CreateFolderAsync(..).AsTask()