locked
Read file from VS project folder in WinRT app

    Question

  • I cant read file from my own folder inside Visual Studio project. It says that cant find it, but folder name is correct and folder included into project 

    var folder = await Package.Current.InstalledLocation.GetFolderAsync("Models");
                var file = await folder.GetFileAsync("SpaceShipV2.aemf");

    On the first line compiler says that folder is missing. What I am doing wrong here?

    And BTW, why IO system in WinRT so limited? What if i just have no free space in that 3 folders which I can access? What I must do then? How to access without user agreement files and folders on the other hard drivers? If I just want to load my content and user don`t need to do it via filepicker manually.

    So, could someone help me to understand this very-very strange concept?

    P.S. I hope that in next version of RT this limitation will be deleted because its mockery. Just compare how easy it was in WPF and how hard it now in WinRT. This just drive me crazy. I cannot beleive that MS set such stupid limits. Strange that they just don`t prohibit access to file system completely....




    Friday, August 1, 2014 5:28 PM

Answers

  • Make sure your asset is flagged as content o it will be copied to the appxpackage and installed with the app. The app doesn't run from the source directory and so cannot see files there.

    Friday, August 1, 2014 6:03 PM
    Owner

All replies

  • Make sure your asset is flagged as content o it will be copied to the appxpackage and installed with the app. The app doesn't run from the source directory and so cannot see files there.

    Friday, August 1, 2014 6:03 PM
    Owner
  • Could you say about it more detail? Where I can make sure that my asset is flagged as content?
    Friday, August 1, 2014 6:47 PM
  • Right click the file in the solution explorer and examine its properties.
    Friday, August 1, 2014 6:49 PM
    Owner