private IEnumerable <string> GetFiles(string path)
        {
            foreach (var file in Directory.EnumerateFiles(path))
            {
                var args = new ItemFoundInfoEventArgs {
                    ItemName = file
                };
                _args.Add(args);
                OnFileFound(args);

                if (_filter(file) && !args.Exclude)
                {
                    if (_args.Any(a => a.Stop))
                    {
                        yield break;
                    }

                    var argsFilteredFile = new ItemFoundInfoEventArgs {
                        ItemName = file
                    };
                    _args.Add(argsFilteredFile);
                    OnFilteredFileFound(argsFilteredFile);

                    if (_args.Any(a => a.Stop))
                    {
                        yield break;
                    }

                    if (!argsFilteredFile.Exclude)
                    {
                        yield return(file);
                    }
                }
            }
        }
        private IEnumerable <string> GetDirectories(string path)
        {
            foreach (var subFolder in Directory.EnumerateDirectories(path))
            {
                var args = new ItemFoundInfoEventArgs {
                    ItemName = path
                };
                _args.Add(args);
                OnDirectoryFound(args);

                if (_filter(subFolder) && !args.Exclude)
                {
                    if (_args.Any(a => a.Stop))
                    {
                        yield break;
                    }

                    var argsFilteredDirectory = new ItemFoundInfoEventArgs {
                        ItemName = path
                    };
                    _args.Add(argsFilteredDirectory);
                    OnFilteredDirectoryFound(argsFilteredDirectory);

                    if (_args.Any(a => a.Stop))
                    {
                        yield break;
                    }

                    if (!argsFilteredDirectory.Exclude)
                    {
                        yield return(subFolder);
                    }
                }
                foreach (var element in GetDirectories(subFolder))
                {
                    yield return(element);
                }
            }

            foreach (var file in GetFiles(path))
            {
                yield return(file);
            }
        }
 protected virtual void OnFilteredDirectoryFound(ItemFoundInfoEventArgs e)
 {
     FilteredDirectoryFound?.Invoke(this, e);
 }
 protected virtual void OnFileFound(ItemFoundInfoEventArgs e)
 {
     FileFound?.Invoke(this, e);
 }