Click here to Skip to main content
15,881,092 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
>Why guys from Microsoft change all upside down after each .net edition? I have tried to do few simples things in new 'metro style' xaml but nothing is simple today. For example I needed to scan a hard disk drive to get list of files. This is very simple task isn't it?

But please tell me why this pretty simple chunk of code doesn't work
XML
using Windows.Storage;
....

async Task AllFilesIwantToGet()
       {
           StorageFolder sf = 
            await StorageFolder.GetFolderFromPathAsync(@"d:\mydocs");


           IReadOnlyList<IStorageItem> list= await sf.GetItemsAsync();


It looks like GetFolderFromPathAsync() never stops and variable sf is null all the time. I was trying to find solution on MSDN but there is nothing that could help.
I thought it's a permission issue but when I use the following code
XML
var sf = await StorageFolder.GetFolderFromPathAsync(KnownFolders.MusicLibrary.Path);


it never ends up too allthough I have added capabilities to MusicLirary.

Sorry for this but after 10 years of programming I feel still like a newbie. This is annoying. Needless to say that Microsoft shots his own foot again.
Posted
Updated 4-Aug-12 23:24pm
v3

You cannot use storagefolder for unknown folders. You have to use filepicker.

Check this,

http://msdn.microsoft.com/en-us/library/windows/apps/jj150596.aspx[^]
 
Share this answer
 
For your updated question...

you have to use


In case u want folders, then

C#
StorageFolder musicFolder = await KnownFolders.MusicLibrary;


If you want file list

XML
IReadOnlyList<StorageFile> fileList =
               await KnownFolders.MusicLibrary.GetFilesAsync();
 
Share this answer
 
Comments
aquant 5-Aug-12 12:51pm    
Thank you Santhosh. I have all these problems because I'd like to write a tool in metro style rather then toy-app. The tool should have access to the whole filesystem's structure (something like file manager). I just couldn't agree with the general asumption that a win8 user cannot access to its own system. The user shouldn't even know what is a filesystem when using a Metro app in Win8.
I think there is a solution to get access to filesystem programmatically. Just think about FileOpenPicker which have access to the most files and can be used by a normal user. Why one 'metro' class can browse filesystem and other class cannot do this (due to security reasons?)
regards
Andy

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