-
Notifications
You must be signed in to change notification settings - Fork 0
Version 2.3 Changes
MH edited this page Dec 17, 2020
·
1 revision
In version 2.3, the ability to perform custom file and folder filtering is provided.
Example:
dirSearch = new DirSearch("*.*", @"c:\", AttrSearchType.IgnoreAttributeMatch, DirSearch.AllAttributes, true);
dirSearch.OnFileMatch += OnFileInitialMatch;
dirSearch.OnFolderMatch += OnFolderInitialMatch;
// the next two delegates are new
dirSearch.OnFolderFilter += OnFolderFilter;
dirSearch.OnFileFilter += OnFileFilter;
dirSearch.Execute();
dirSearch.OnFileMatch -= OnFileInitialMatch;
dirSearch.OnFolderMatch -= OnFolderInitialMatch;
dirSearch.OnFolderFilter -= OnFolderFilter;
dirSearch.OnFileFilter -= OnFileFilter;
private void OnFileFilter(FileInfo fileInfo, ref bool skip) {
// perform file filtering here
// set skip to true to skip file; if set, OnFileMatch will not be triggered later
}
private void OnFolderFilter(DirectoryInfo folderInfo, ref bool skip, ref bool skipChildFolders) {
// perform folder filtering here
// set skip to true to skip folder but continue with child folders.
// set skipChildFolders to skip enumeration of subfolders
// for skipped folders, OnFolderMatch will not be triggered later
}