加载OneDrive文档

时间:2014-10-21 02:11:20

标签: c# .net windows-store-apps windows-store onedrive

我正在开发Windows应用商店应用。我有一个OneDrive文档的路径。我尝试使用以下方式打开它:

await StorageFile.GetFileFromPathAsync(path);

我知道该文件存在,因为我可以导航到它(C:\Users\User\OneDrive\Documents\Example.txt),但由于某种原因等待GetFileFromPathAsync总是抛出异常。我从我的MainPage构造函数中调用的函数调用此代码,如下所示:

public MainPage()
{
    ...
    LoadFile("C:\\Users\\User\\OneDrive\\Documents\\Example.txt");
    ...
}

private async void LoadFile(string path)
{
    await StorageFile.GetFileFromPathAsync(path);
}

有什么问题?

0 个答案:

没有答案