Tehreem
Tehreem

Reputation: 999

Error while reading a file with GetFileAsync

I have written this line of code:

file = await Package.Current.InstalledLocation.GetFileAsync("ms-appx:///Images/Hair Cuts/HC_1.jpg");

But it throws this exception:

WinRT information: An item cannot be found with the specified Name
(ms-appx:///Images/Hair Cuts/HC_1.jpg). 

This image does exist in the specified folder. Can anyone help?

Upvotes: 1

Views: 2155

Answers (1)

Deani Hansen
Deani Hansen

Reputation: 722

In order to retrieve the file, try using the code from the MSDN documentation:

using Windows.Storage;

.

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///Images/Hair Cuts/HC_1.jpg");

Upvotes: 3

Related Questions