예제 #1
0
        /// <summary>
        /// Starts the search.
        /// </summary>
        public void Start()
        {
            try
            {
                foreach (var file in Settings.InDirectory.EnumerateFiles())
                {
                    if (Settings.Target == file)
                    {
                        NodeFound?.Invoke(file);
                    }
                }
                ct.ThrowIfCancellationRequested();


                List <DirectoryInfo> dirsToBeSearched = null;
                if (Settings.SearchSubdirectories)
                {
                    dirsToBeSearched = new List <DirectoryInfo>();
                }

                foreach (var dir in Settings.InDirectory.EnumerateDirectories())
                {
                    if (Settings.Target == dir)
                    {
                        NodeFound?.Invoke(dir);
                    }

                    if (Settings.SearchSubdirectories && IsFolderReadable(dir))
                    {
                        dirsToBeSearched.Add(dir);
                    }
                }

                ct.ThrowIfCancellationRequested();


                foreach (var dir in dirsToBeSearched)
                {
                    Factory.CreateFromParentSearchJob(this, dir).Start();
                }
            }
            catch (Exception e) when(e is SecurityException || e is UnauthorizedAccessException || e is DirectoryNotFoundException)
            {
                ExceptionRise?.Invoke(new FileSystemNodeSearchException(Settings.InDirectory, e));
            }
        }
예제 #2
0
 private void nodeFound(IPAddress ip, string name)
 {
     NodeFound?.Invoke(ip, name);
 }