コード例 #1
0
        private void ProcessFiles(string currentDir)
        {
            if (!GetFiles(currentDir, out var files))
            {
                return;
            }

            // performs the required action on each file
            FileInfo fileInfo;

            foreach (var file in files)
            {
                if (_excludes.Contains(file, StringComparer.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                try
                {
                    fileInfo = new FileInfo(file);
                    if (_excludes.Contains(fileInfo.Name))
                    {
                        continue;
                    }

                    _reporter.AddFile(fileInfo);
                }
                catch (FileNotFoundException e)
                {
                    // if the file was deleted by a separate application or thread since the call to TraverseTree() then just continue.
                    Console.WriteLine(e.Message);
                }
            }
        }