Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Win8
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:
var folders = await KnownFolders.DocumentsLibrary.GetFoldersAsync();
if anyone guide me. Thanks in advance.
Posted 4-Oct-12 4:20am
Edited 4-Oct-12 5:06am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<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:
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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 CPallini 375
2 BillWoodruff 314
3 George Jonsson 279
4 OriginalGriff 227
0 OriginalGriff 5,030
1 CPallini 4,225
2 Sergey Alexandrovich Kryukov 3,604
3 George Jonsson 2,831
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 5 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100