/// <summary> /// Gets <see cref="FileData"/> for all the files in a directory. /// </summary> /// <param name="path">The path to search.</param> /// <returns>An object that implements <see cref="IEnumerable{FileData}"/> and /// allows you to enumerate the files in the given directory.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="path"/> is a null reference (Nothing in VB) /// </exception> public static IEnumerable <FileData> EnumerateFiles(string path) { var filesystemSearchOptions = new FilesystemSearchOptions(); filesystemSearchOptions.FileSpecifier = new FileSpecifier("*"); return(FastDirectoryEnumerator.EnumerateFiles(path, filesystemSearchOptions)); }
public FilesystemSearchOptions(FilesystemSearchOptions source) { this.IsIncludingHiddenFiles = source.IsIncludingHiddenFiles; this.IsRecursiveSearch = source.IsRecursiveSearch; this.IsFilesOnly = source.IsFilesOnly; this.FileSpecifier = source.FileSpecifier; this.PathExclusions = source.PathExclusions; }
/// <summary> /// Initializes a new instance of the <see cref="FileEnumerator"/> class. /// </summary> /// <param name="path">The path to search.</param> /// <param name="filter">The search string to match against files in the path.</param> /// <param name="searchOption"> /// One of the SearchOption values that specifies whether the search /// operation should include all subdirectories or only the current directory. /// </param> public FileEnumerator(string path, FilesystemSearchOptions filesystemSearchOptions) { _path = path; _searchOptions = filesystemSearchOptions; _isSelectingWithFileSpec = !_searchOptions.FileSpecifier.IsNonSpecific; if (_searchOptions.IsRecursiveSearch) { _stackOfHandles = new Stack <SearchContext>(); } }
/// <summary> /// Gets <see cref="FileData"/> for all the files in a directory that match a /// specific filter. /// </summary> /// <param name="path">The path to search.</param> /// <param name="searchPattern">The search string to match against files in the path.</param> /// <returns>An object that implements <see cref="IEnumerable{FileData}"/> and /// allows you to enumerate the files in the given directory.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="path"/> is a null reference (Nothing in VB) /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="filter"/> is a null reference (Nothing in VB) /// </exception> //public static IEnumerable<FileData> EnumerateFiles(string path, string searchPattern) //{ // return FastDirectoryEnumerator.EnumerateFiles(path, searchPattern, SearchOption.TopDirectoryOnly); //} /// <summary> /// Gets FileData for all the files in a directory that qualify under the given FilesystemSearchOptions. /// </summary> /// <param name="path">The path to search.</param> /// <param name="filesystemSearchOptions"> /// An object that specifies search criteria such as a filespec, andwhether the search /// operation should include all subdirectories or only the current directory. /// </param> /// <returns>An object that implements <see cref="IEnumerable{FileData}"/> and /// allows you to enumerate the files in the given directory.</returns> public static IEnumerable <FileData> EnumerateFiles(string path, FilesystemSearchOptions filesystemSearchOptions) { if (path == null) { throw new ArgumentNullException("path"); } if (filesystemSearchOptions.FileSpecifier == null) { throw new ArgumentNullException("FileSpecifier"); } string fullPath = Path.GetFullPath(path); return(new FileEnumerable(fullPath, filesystemSearchOptions)); }
/// <summary> /// Initializes a new instance of the <see cref="FileEnumerable"/> class. /// </summary> /// <param name="path">The path to search.</param> /// <param name="filesystemSearchOptions">An object that specifies search criteria such as the pattern to match files against</param> public FileEnumerable(string path, FilesystemSearchOptions filesystemSearchOptions) { _path = path; _filesystemSearchOptions = filesystemSearchOptions; }