I am running win8.1 , and VS2013 SP3, trying to create a windows phone app which should retrieve all the document names and paths (for later reference) from the 'Assets' folder. I added a bunch of word documents in the Assets folder and set the build to content, and copy to always.
Is it possible to get a list of all files (or file names) in the assets folder? I can't seem to find the way to do it.
What I can do is reference a specific file, but what I would like to do, is list out all the file names/paths within the Assets folder and show the details of these files in a specific view...
I tried the following:
var package = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetsFolder = await package.GetFolderAsync("Assets");
foreach (var file in await assetsFolder.GetFilesAsync())
{
_documents.Add(new Document() { Category = section, Title = file.Name, Uri = file.Path });
}
This code freezes on the foreach line...?
I would very much appreciate some guidance or references in this matter.
Maybe it's the way you're calling it.
Here's mine with screenshots.
I only call it once the whole page has loaded.
private void Page_Loaded(object sender, RoutedEventArgs e)
{
ReadAssetFolder();
}
public async void ReadAssetFolder()
{
var package = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assetsFolder = await package.GetFolderAsync("Assets");
foreach (var file in await assetsFolder.GetFilesAsync())
{
int debug_var = 1;
}
}
Screenshot of when the debugger hits my breakpoint:

Screenshot of my Asset folder

Finally all my files have these Properties

Hope that helps you.
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