简洁优雅的.net代码赏析
1. 获取指定目录下所有的文件全路径:
public IEnumerable<String> GetFiles(string dir)
{
foreach (String file in System.IO.Directory.GetFiles(dir, "*.*", System.IO.SearchOption.AllDirectories)) {
yield return file;
}
{
foreach (String file in System.IO.Directory.GetFiles(dir, "*.*", System.IO.SearchOption.AllDirectories)) {
yield return file;
}
}