For UWP, it is easy to get all files in the app local folder as:
IReadOnlyList<StorageFile> files = await ApplicationData.Current.LocalFolder.GetFilesAsync();
You can now iterate on the files list and even get further info on individual files.
I would like a similar all-file-getter for an app folder, for instance, consider the /Assets folder where app *.png files are stored. Single file with a known name is no problem; I can refer to it quite easily as:
StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Assets/StoreLogo.png"))
My question is, therefore, is there a similar thing for getting all files in an app folder, such as /Assets folder? Logically, it should be something like StorageFile.GetFilesFromApplicationFolderUriAsync(new Uri(@"ms-appx:///Assets"))
but unaware if an equivalent of the LocalFolder shown above exists.
You can access you installation folder by using Package.InstalledLocation. Therefore your code can look like this:
StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFolder assets = await appInstalledFolder.GetFolderAsync("Assets"); var files = await assets.GetFilesAsync();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With