Click here to Skip to main content
Rate this: bad
good
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 22:45pm
aquant617
Edited 5-Aug-12 0:24am
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Rate this: bad
good
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();
  Permalink  
Comments
aquant at 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)

  Print Answers RSS
0 OriginalGriff 290
1 Jochen Arndt 165
2 DamithSL 125
3 PIEBALDconsult 110
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 5 Aug 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