I am working on a Windows Store app. I have a path to a OneDrive document. I try to open it using:
await StorageFile.GetFileFromPathAsync(path);
I know the file is present, as I can navigate to it (C:\Users\User\OneDrive\Documents\Example.txt
), but for some reason awaiting GetFileFromPathAsync
always throws an exception. I am calling this code from a function which is called within my MainPage
constructor, something like this:
public MainPage()
{
...
LoadFile("C:\\Users\\User\\OneDrive\\Documents\\Example.txt");
...
}
private async void LoadFile(string path)
{
await StorageFile.GetFileFromPathAsync(path);
}
What is the problem?