private static string FindWritableImplantPath(string root) { foreach (string f in SafeWalk.EnumerateFiles(root, "*.dll", SearchOption.AllDirectories)) { string p = Path.GetDirectoryName(f); if (CheckDirectoryWritePrivilege(p, FileSystemRights.FullControl)) { return(p); } } return(""); }
public void Run() { //see if we have a single file, path if (File.Exists(Path)) { _RunFile(Path); } else { foreach (var file in SafeWalk.EnumerateFiles(Path, "*", SearchOption.AllDirectories)) { _RunFile(file); } } }
public void IndexDirectory(string path, HashSet <string> ignoredDirectories, ExtensionContainer extensionContainer) { if (string.IsNullOrWhiteSpace(path)) { return; } try { var traverseDirectoriesWatch = Stopwatch.StartNew(); var allFiles = SafeWalk.EnumerateFiles(path, ignoredDirectories); var paths = allFiles .Where(x => extensionContainer.IsKnownExtension(Path.GetExtension(x))) .Distinct() .ToArray(); traverseDirectoriesWatch.Stop(); var indexWatch = Stopwatch.StartNew(); try { _lock.EnterWriteLock(); _indexData.Update(path, paths); SaveIndex(); } finally { _lock.ExitWriteLock(); } indexWatch.Stop(); var traverseMs = traverseDirectoriesWatch.ElapsedMilliseconds; var indexMs = indexWatch.ElapsedMilliseconds; var totalMs = indexWatch.ElapsedMilliseconds + traverseDirectoriesWatch.ElapsedMilliseconds; Log.Information($"Index {path} - {paths.Length} items. [ {totalMs} ms, tra: {traverseMs} ms, idx: {indexMs} ms ]"); } catch (Exception e) { Log.Error(e, "Failed to index path: {path}, message: {message}", path, e.Message); } }
private static string FindLocalDbUtility() { return(SafeWalk.EnumerateFiles("C:\\Program Files\\Microsoft SQL Server", "SqlLocalDb.exe", SearchOption.AllDirectories).OrderBy(p => p) .LastOrDefault()); }