Home > Software engineering >  GetFileFromApplicationUriAsync throws "The system cannot find the file specified"
GetFileFromApplicationUriAsync throws "The system cannot find the file specified"

Time:10-05

I really don't get why I am getting this exception: "The system cannot find the file specified".

Please check the code below. I was able to get file test3 but unable to get test2. I am pretty sure they are under the same folder. And I also wasn't able to read other files under the ms-appx path except for the png files under the Assets folder.

Can somebody please help? This is the link to my code and this is the link to the Assets folder.

  var test3 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/folder.png"));
  var test2 = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/zh.grxml"));

CodePudding user response:

In the project file you will see this

<Content Include="Assets\folder.png" />
<None Include="Assets\zh.grxml" />

Make zh.grxml copy to the output directory (one way or another) and you will have consistent results

Example

<Content Include="Assets\zh.grxml" />
  • Related