How to get file from Instaled location

BitSmithy 1,771 Reputation points
2022-06-13T20:01:57.55+00:00

Hello,

In app tree in VS, I have folder called GameScenarios
Inside this folder I store file.

I tray to get this file from app using

StorageFolder appInstalationFolder = Package.Current.InstalledLocation;  
StorageFolder scenariosFolder = await appInstalationFolder.GetFolderAsync("GameScenarios");  
var scenarioFile = await scenariosFolder.GetFileAsync(gameFileName);  

But file is not found.
Hw to get file attached to app as a app content?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,856 Reputation points
    2022-06-14T03:44:04.763+00:00

    Hello,
    Welcome to Microsoft Q&A!

    I have used your code to access simple file where under GameScenarios folder, and I could access file successfully. If you view file not found exception, please check if your file's build action is content.(right click the file -> properties -> build action). And you need also to check if gameFileName is correct.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful