Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- await searchRecursively(@"c:\Users\xPucTu4\Downloads\", new Regex(@"^.*\.mp3", RegexOptions.IgnoreCase));
- async Task searchRecursively(string rootPath, Regex searchRegex)
- {
- await Task.CompletedTask;
- if (this.QueryCancelToken.IsCancellationRequested)
- return;
- DirectoryInfo di = new(rootPath);
- foreach (var subDir in di.GetDirectories())
- {
- try
- {
- await searchRecursively(subDir.FullName, searchRegex);
- }
- catch { }
- }
- var matches = di.GetFiles()
- .Where(f => searchRegex.IsMatch(f.Name));
- if (matches.Any())
- matches
- .OrderByDescending(m => m.CreationTime)
- .Select(f => new { f.FullName, f.CreationTime, f.Length, Open = createOpenFolderButton(f.FullName) }).Dump();
- }
- Button createOpenFolderButton(string fileName)
- {
- Button buttonOpenDir = new Button("Open");
- buttonOpenDir.Click += (s, a) =>
- {
- Process.Start("explorer.exe", $"/select,\"{fileName}\"");
- };
- return buttonOpenDir;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement