Read file from subfolder of application installation folder

前端 未结 4 847
逝去的感伤
逝去的感伤 2021-01-15 11:13

I have to read the text content from an .txt file, this file is located in app installed folder, in a subfolder, according to Microsoft docs, I am doing it like

4条回答
  •  一个人的身影
    2021-01-15 12:04

    you can do it in other way, using URI :

    using Windows.Storage;
    StorageFile file = await StorageFile.GetFileFromApplicationUriAsync("ms-appx:///file.txt");
    

    So in your case it will be:

    StorageFile txtfile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///myfolder/myfile.txt"));
    

提交回复
热议问题