void Traverse(string directory, DirectoryTraverserResult result)
        {
            try
            {
                var dirInfo = new DirectoryInfo(directory);
                result.Directories++;
                OnDirectory?.Invoke(dirInfo);

                if (OnFile != null)
                {
                    foreach (var file in dirInfo.EnumerateFiles())
                    {
                        OnFile.Invoke(file);
                    }
                }

                foreach (var dir in dirInfo.EnumerateDirectories())
                {
                    Traverse(Path.Combine(directory, dir.Name), result);
                }
            }
            catch
            {
                result.Exceptions++;
            }
        }
        public DirectoryTraverserResult Traverse(string startDirectory)
        {
            var result = new DirectoryTraverserResult {
                StartDirectory = startDirectory
            };

            Traverse(startDirectory, result);
            result.EndTime = DateTime.Now;
            return(result);
        }