我不知道为什么我们会使用Directory.GetFiles,如果Directory.EnumerateFiles能够做同样的事情,你甚至可以在返回找到的整个目录列表之前枚举列表.
What is the difference between Directory.EnumerateFiles vs Directory.GetFiles?
为什么,既然EnumerateFiles可用,是否需要使用GetFiles?
解决方法
根据
http://msdn.microsoft.com/en-us/library/07wt70x2%28v=vs.110%29.aspx:
The EnumerateFiles and GetFiles methods differ as follows: When you
use EnumerateFiles,you can start enumerating the collection of names
before the whole collection is returned; when you use GetFiles,you
must wait for the whole array of names to be returned before you can
access the array. Therefore,when you are working with many files and
directories,EnumerateFiles can be more efficient.
我猜GetFiles可以被认为是一个方便的功能.