system.io.directory

What happens with Directory.EnumerateFiles if directory content changes during iteration?

偶尔善良 提交于 2019-11-28 04:40:44
问题 I've read discussions about difference between Directory.EnumerateFiles and Directory.GetFiles(). I understand that internally they both use System.IO.FileSystemEnumerableFactory.CreateFileNameIterator() The difference is that EnumerateFiles might use deferred execution (lazy), while GetFiles() does a ToArray, so the function is already executed. But what happens if files and folders are added to the dictionary during the iteration. Will the iteration only iterate over the items that were

Multiple file-extensions searchPattern for System.IO.Directory.GetFiles

北慕城南 提交于 2019-11-26 21:33:42
What is the syntax for setting multiple file-extensions as searchPattern on Directory.GetFiles() ? For example filtering out files with .aspx and .ascx extensions. // TODO: Set the string 'searchPattern' to only get files with // the extension '.aspx' and '.ascx'. var filteredFiles = Directory.GetFiles(path, searchPattern); Update : LINQ is not an option , it has to be a searchPattern passed into GetFiles , as specified in the question. Daniel B I believe there is no "out of the box" solution, that's a limitation of the Directory.GetFiles method. It's fairly easy to write your own method

Multiple file-extensions searchPattern for System.IO.Directory.GetFiles

不羁的心 提交于 2019-11-26 07:57:23
问题 What is the syntax for setting multiple file-extensions as searchPattern on Directory.GetFiles() ? For example filtering out files with .aspx and .ascx extensions. // TODO: Set the string \'searchPattern\' to only get files with // the extension \'.aspx\' and \'.ascx\'. var filteredFiles = Directory.GetFiles(path, searchPattern); Update : LINQ is not an option , it has to be a searchPattern passed into GetFiles , as specified in the question. 回答1: I believe there is no "out of the box"