WinRT:用于枚举库和已知文件夹之外的文件的应用程序 [英] WinRT: App to enumerate files outside libraries and known folders
问题描述
我正在开发一个 Metro 应用程序,该应用程序在 ListView 控件中显示给定文件夹的内容.MS 决定开发人员不需要 System.IO.Directory 类并将其从框架中完全删除.
I am working on a Metro app that shows the content of a given folder in a ListView control. MS decided that developers don't need the System.IO.Directory class and removed it entirely from the framework.
我正在寻找在 Metro 风格应用程序中枚举 C# 文件的替代方法.我检查了 MS 提供的所有枚举示例,它们似乎都只使用 KnownFolders
类枚举 Windows 库,例如:
I am looking for a replacement to enumerate files in C# in a metro style app. I have checked all the enumeration samples provided by MS and they all seem to only enumerate the Windows Libraries using the KnownFolders
class, something like:
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
并根据您的需要调用 GetFilesAsync()
或 GetFoldersAsync()
方法.如果我只想在图片或音乐库中枚举,这些都是金子.但是,我希望枚举库中未包含的目录中的文件.
and calling the GetFilesAsync()
or GetFoldersAsync()
methods depending on your needs. These are all gold if I wanted to enumerate only inside the pictures or music library. However I am looking to enumerate files on directories that are not included in a library.
任何人都知道这在 WinRT 中是如何实现的???
Anyone knows how this is possible in WinRT???
推荐答案
根据设计,您在此领域对于 Metro 应用程序的限制非常有限.这个想法是,Metro 应用只能访问它信任访问的内容,因此您可以:
You are, by design, extremely limited in this area for Metro apps. The idea is that a Metro app is only given access to those things that it is trusted to access, so you can either:
- 访问本地存储,特定于您的应用
- 访问一些众所周知的存储位置,或
- 访问特别授予的位置.
看看 http://msdn.microsoft.com/en-us/library/windows/apps/hh464959.aspx 以了解您可以访问的内容.
Take a look at http://msdn.microsoft.com/en-us/library/windows/apps/hh464959.aspx to get an idea as to what you'll be able to access.
这篇关于WinRT:用于枚举库和已知文件夹之外的文件的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!