private void SearchWork(BackgroundWorker worker, SearchArguments args) { var directoryInfo = new DirectoryInfo(args.RootPath); foreach (var fi in directoryInfo.GetFiles()) { args.SetCurrentFileLable(fi.Name); if (worker.CancellationPending) { return; } if (!fi.Name.IsNormalized()) { string fixedFullName = Path.Combine(fi.DirectoryName, fi.Name.Normalize()); args.AddRow(fi.FullName, fixedFullName, "파일"); } } foreach (var di in directoryInfo.GetDirectories()) { if (worker.CancellationPending) { return; } if (args.IsIncludeSubDirectory) { SearchWork(worker, args.Clone(di.FullName)); } args.SetCurrentFileLable(di.Name); if (!args.IsIncludeDirectory) { continue; } string parentDirectory = Path.GetDirectoryName(di.FullName); string currentDirectory = Path.GetFileName(di.FullName); if ((parentDirectory == null || parentDirectory == String.Empty) && !currentDirectory.IsNormalized()) { args.AddRow(di.FullName, di.FullName, "폴더"); } if (!currentDirectory.IsNormalized()) { // 순서상 서브 디렉토리의 변경이 먼저 되어야 하기 때문에 디렉토리는 나중에 넣는다. string fixedFullName = Path.Combine(parentDirectory, currentDirectory.Normalize()); args.AddRow(di.FullName, fixedFullName, "폴더"); } } }
public void SetCriteria(SearchCriteria searchCriteria) { searchArguments = new SearchArguments(searchCriteria, labelCurrentFile); }