【发布时间】:2015-12-20 04:09:29
【问题描述】:
我正在尝试使用以下内容读取文件:
public static async Task<JsonObject> read(string nome)
{
nome = GetSafeFilename(nome);
string json = "";
try
{
StorageFolder folder = ApplicationData.Current.LocalFolder;
Debug.WriteLine("here? folder");
StorageFile jsonFile = await folder.GetFileAsync(nome);
Debug.WriteLine("here? file");
json = await FileIO.ReadTextAsync(jsonFile);
Debug.WriteLine("here? fileio" + json);
}
catch ( Exception ex )
{
Debug.WriteLine(ex.StackTrace);
}
return JsonObject.Parse(json); //converte string para jsonobject
}
但是应用程序冻结了应用程序并且没有抛出任何异常。 “Console.Writeline”停在“这里?文件”中。
我做错了吗?
【问题讨论】:
-
async关键字应该在static之后.. -
操作。我的错误,但不是解决方案..
-
如果是真的,它就不会编译。
标签: c# async-await uwp