Click here to Skip to main content
13,150,622 members (45,463 online)
Rate this:
Please Sign up or sign in to vote.
>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
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
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 4-Aug-12 21:45pm
Updated 4-Aug-12 23:24pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

Check this,[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

For your updated question...

you have to use

In case u want folders, then

StorageFolder musicFolder = await KnownFolders.MusicLibrary;

If you want file list

IReadOnlyList<StorageFile> fileList =
               await KnownFolders.MusicLibrary.GetFilesAsync();
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?)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 5 Aug 2012
Copyright © CodeProject, 1999-2017
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