Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm getting the documentlibrary folders. but i don't know how to display the geeting folders in a MainPage.Xaml design page.

here is my code:
C#
var folders = await KnownFolders.DocumentsLibrary.GetFoldersAsync();

if anyone guide me. Thanks in advance.
Posted
Updated 4-Oct-12 5:06am
v2

HTML
<grid grid.row="1">
            <grid.rowdefinitions>
                <rowdefinition height="Auto"></rowdefinition>
                <rowdefinition height="Auto"></rowdefinition>
            </grid.rowdefinitions>
                    <listview x:name="FolderList" horizontalalignment="Left" height="Auto" margin="125,30,0,0" verticalalignment="Top" width="250" removed="#FF636E5D" xmlns:x="#unknown">
                <listview.itemtemplate>
                            <datatemplate>
                                <textblock text="{Binding DisplayName}"></textblock>
                            </datatemplate>
                        </listview.itemtemplate>
                    </listview>         
        </grid>

Now, in code behind write following code:
C#
protected async override void LoadState(Object navigationParameter, Dictionary<string,> pageState)
        {
            var folders = await Windows.Storage.KnownFolders.DocumentsLibrary.GetFoldersAsync();
            var data = folders.ToList<windows.storage.storagefolder>();
            FolderList.ItemsSource = data;
        }

This will show all the folders within the DocumentsLibrary in ListView.
 
Share this answer
 
v2
Use GetFilesAsync() to retrieve the files in the folder, then for each retrieved item, display its Path property (assuming that's what you want to display).

/ravi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900