Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winphone8.1 development: Can I get a List of al files stored within the Assets folder?

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.

like image 972
Javi Kroonenburg Avatar asked Dec 05 '25 20:12

Javi Kroonenburg


1 Answers

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:

enter image description here


Screenshot of my Asset folder

enter image description here


Finally all my files have these Properties

enter image description here

Hope that helps you.

like image 163
Chubosaurus Software Avatar answered Dec 07 '25 13:12

Chubosaurus Software