Get file paths for files in Centennial app

2019-09-21 18:14发布

问题:

When converting an app to a Windows Store app, we add the files as mentioned here. But now - how do we access them? What's their path?

They're not in the special folder created for the package.

回答1:

You can create a folder structure in your project where you can include the files and then since you are already crossing the Centennial Bridge, you can start using the Windows.Storage.StorageFile WinRT API to interact with files.

For example, you can use: StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///folderUnderYourAppRoot/image.bmp")); to get the file which is under the "folderUnderYourAppRoot". This is the generic guidance: https://msdn.microsoft.com/en-us/windows/uwp/files/quickstart-reading-and-writing-files, so you can review it further...