我正在尝试.mp3
从多个文件夹中获取文件。
我已经可以通过此查询为一个文件夹执行此操作:
this.MusicList.ItemsSource =
from string fileName in Directory.GetFiles(@"C:\Users\Public\Music\Sample Music")
where System.IO.Path.GetExtension(fileName) == ".mp3"
select new FileInfo(fileName);
对于目录列表还有其他方法吗?
这是我迄今为止尝试过的(没有返回结果):
var paths = new Dictionary<string, string> {
{"default_music", @"C:\Users\Public\Music\Sample Music"},
{"alternative_folder", @"C:\tmp"}
};
this.MusicList.ItemsSource =
from string fileName in (from string directoryName in paths.Values select Directory.GetFiles(directoryName))
where System.IO.Path.GetExtension(fileName) == ".mp3"
select new FileInfo(fileName);
from string directoryName in paths.Values select Directory.GetFiles(directoryName);
在其字段中返回{System.Linq.Enumerable.WhereSelectEnumerableIterator<string,string[]>}
带有我的路径及其包含我的文件的 a。source
Result View
.mp3
谢谢