Winphone8.1 development: can I get a list of al files stored in the Assets folder?
I am running win8.1 and VS2013 SP3 trying to create a Windows phone app that should get all the document names and paths (for later reference) from the Assets folder. I added a bunch of text documents to the Assets folder and set the build to content and always copied.
Is it possible to get a list of all files (or filenames) in the assets folder? I can't seem to find a way to do this.
What I can do is link to a specific file, but what I would like to do is list all the filenames / paths in the Assets folder and show the details of those 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 });
}
Does this code hang at the foreach line ...?
I would really appreciate some guidance or guidance on this matter.
source to share
Perhaps that's what you call him.
Here are mine with screenshots.
I only call this after 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 assets folder
Finally, all my files have the following properties
Hope it helps.
source to share