Answered How to get a list of files or folders

  • 05 Agustus 2012 17:22
     
      Memiliki Kode

    I have tried the following chunk of code to get StorageFolder object

    sf = await StorageFolder.GetFolderFromPathAsync(@"D:\");

    and of course it doesn't work. This means the called thread never stops or better it throws an exeption

    "Value does not fall within the expected range."

    I have read few articles and stated that metro app is not allowed to get access to true filesystem. Well I should use something like this

    sf = KnownFolders.MusicLibrary;

    because so called 'known folders' are the only ones my app can get access to. So we should say bye bye to the old classes like DirectoryInfo, FileInfo? Are we really allowed to write only toy-application for kids?

    My problem has emerged when I had tried to write a sample metro-style 'file manager'. This type of apps must have access to the filesystem. Is this possible to hack this metro restrictions or I should give the metro up and not waste time anymore.

     



    • Diedit oleh Andrzey 05 Agustus 2012 17:49
    •  

Semua Balasan

  • 05 Agustus 2012 18:34
    Moderator
     
     Jawab

    Your file manager app would need to be a desktop app.

    The new Windows 8 style apps are sandboxed so they cannot access the user's files without permission. They have direct access to their install and application data folder, but not other parts of the file system. As you note, they can get brokered access to the libraries via capabilities declarations, and they can get brokered access elsewhere with the user's permission via file or folder pickers.

    See File access and permissions in Metro style apps for more detail.

    --Rob

    • Ditandai sebagai Jawaban oleh Andrzey 05 Agustus 2012 18:55
    •  
  • 05 Agustus 2012 18:34
     
      Memiliki Kode

    I hope thats a honest question and not a threat,

    Anyway you can use the installed location of your app in addition to that you can use Skydrive folder location

    See 

    Windows.ApplicationModel.Package.Current.InstalledLocation


    Zubair Ahmed | @zubairdotnet | zubairahmed.net | MetroRssReader.codeplex.com | facebook.com/zubair.ahmed.public

  • 05 Agustus 2012 19:28
     
     

    Your file manager app would need to be a desktop app.

    [...]

    --Rob

    Well,

    There the same reasons as in the case of  Excel, or better Access 2007 which as default doesn't run its own applications until user sees a message 'for security reasons macros are not allowed', understands the message and gets know how to turn the macros on.

    This is why almost nobody use Access although it's really good and powerful program.

    The similar (paranojic) idea has killed WPF apps run in webbrowsers (XBAP files). Due to certifications and other security issues allmost every surfer never opens xbap app in his/her browser, because he feel fear.

    I think that due to sandboxes and other issues (e.g. running in background, no possibility of self closing (quit) etc.) WinRT cannot handle wide range of productivity applications but only few games or maybe music players. This looks like WinRT replicates Android.


    • Diedit oleh Andrzey 05 Agustus 2012 19:28
    •  
  • 11 Agustus 2012 4:40
     
     

    Based on the reply from Rob Caplan, I have captured FileNotFoundException, but still I the exception is thrown, instead of going into the catch statement.

    FileNotFoundExecption