Example #1
0
 /// <summary>
 /// Initialzes an instance of the class. Finds all files that
 /// match the wildcard
 /// </summary>
 /// <param name="rootDir">directory to walk</param>
 /// <param name="fileWildCard">files to find</param>
 public DirectoryWalker(String rootDir, String fileWildCard)
 {
     _rootDir           = rootDir;
     _wildCard          = fileWildCard;
     _fileFoundDelegate = null;
     _dirFoundDelegate  = null;
 }
Example #2
0
 /// <summary>
 /// Initialzies an instance of the class.  Finds all
 /// files in the specified directory
 /// </summary>
 /// <param name="rootDir">Directory to walk</param>
 public DirectoryWalker(String rootDir)
 {
     _rootDir           = rootDir;
     _wildCard          = String.Empty;
     _fileFoundDelegate = null;
     _dirFoundDelegate  = null;
 }
Example #3
0
        private void FileFound(int workerId, string fileName)
        {
            OnFileFoundDelegate handler = OnFileFound;

            if (handler != null)
            {
                handler(this, new FileFoundArgs
                {
                    FileName   = fileName,
                    SearcherId = workerId
                });
            }
        }
Example #4
0
        /// <summary>
        /// Walks the directory.  If reecursive is true, goes
        /// into all the subfolders as well. Finds all the sub
        /// folders and matching files in the directory
        /// </summary>
        /// <param name="dirFoundDelegate">invoked when a subfolder is found</param>
        /// <param name="fileFoundDelegate">invoked when a file is found</param>
        /// <param name="recursive">set to true for recursive</param>
        public void Walk(OnDirectoryFoundDelegate dirFoundDelegate, OnFileFoundDelegate fileFoundDelegate, bool recursive = true)
        {
            if (Directory.Exists(_rootDir) && (dirFoundDelegate != null || fileFoundDelegate != null))
            {
                _dirFoundDelegate  = dirFoundDelegate;
                _fileFoundDelegate = fileFoundDelegate;
                if (_fileFoundDelegate != null && String.IsNullOrEmpty(_wildCard))
                {
                    _wildCard = "*.*";
                }

                if (fileFoundDelegate != null)
                {
                    listFiles(_rootDir);
                }

                listDirs(_rootDir, recursive);
            }
        }
Example #5
0
        /// <summary>
        /// Walks the directory.  If reecursive is true, goes
        /// into all the subfolders as well. Finds all the sub
        /// folders and matching files in the directory
        /// </summary>
        /// <param name="dirFoundDelegate">invoked when a subfolder is found</param>
        /// <param name="fileFoundDelegate">invoked when a file is found</param>
        /// <param name="recursive">set to true for recursive</param>
        public void Walk(OnDirectoryFoundDelegate dirFoundDelegate, OnFileFoundDelegate fileFoundDelegate, bool recursive = true)
        {
            if (Directory.Exists(_rootDir) && (dirFoundDelegate != null || fileFoundDelegate != null))
            {
                _dirFoundDelegate = dirFoundDelegate;
                _fileFoundDelegate = fileFoundDelegate;
                if (_fileFoundDelegate != null && String.IsNullOrEmpty(_wildCard))
                {
                    _wildCard = "*.*";
                }

                if (fileFoundDelegate != null)
                {
                    listFiles(_rootDir);
                }

                listDirs(_rootDir, recursive);
            }
        }
Example #6
0
 /// <summary>
 /// Walks the directory.  If reecursive is true, goes
 /// into all the subfolders as well. Finds all the matching
 /// files in the directory
 /// </summary>
 /// <param name="fileFoundDelegate">invoked when a file is found</param>
 /// <param name="recursive">set to true for recursive</param>
 public void Walk(OnFileFoundDelegate fileFoundDelegate, bool recursive = true)
 {
     Walk(null, fileFoundDelegate);
 }
Example #7
0
 /// <summary>
 /// Initialzes an instance of the class. Finds all files that
 /// match the wildcard
 /// </summary>
 /// <param name="rootDir">directory to walk</param>
 /// <param name="fileWildCard">files to find</param>
 public DirectoryWalker(String rootDir, String fileWildCard)
 {
     _rootDir = rootDir;
     _wildCard = fileWildCard;
     _fileFoundDelegate = null;
     _dirFoundDelegate = null;
 }
Example #8
0
 /// <summary>
 /// Initialzies an instance of the class.  Finds all
 /// files in the specified directory
 /// </summary>
 /// <param name="rootDir">Directory to walk</param>
 public DirectoryWalker(String rootDir)
 {
     _rootDir = rootDir;
     _wildCard = String.Empty;
     _fileFoundDelegate = null;
     _dirFoundDelegate = null;
 }
Example #9
0
 /// <summary>
 /// Walks the directory.  If reecursive is true, goes
 /// into all the subfolders as well. Finds all the matching
 /// files in the directory
 /// </summary>
 /// <param name="fileFoundDelegate">invoked when a file is found</param>
 /// <param name="recursive">set to true for recursive</param>
 public void Walk(OnFileFoundDelegate fileFoundDelegate, bool recursive = true)
 {
     Walk(null, fileFoundDelegate);
 }