private void FindItWithMatching(string inputPath, string matchingFileName) { if (!inputPath.EndsWith(@"\")) { inputPath += @"\"; } string[] files = Directory.GetFiles(inputPath, matchingFileName + ".exe", SearchOption.AllDirectories); if (files.Length > 0) { if (ApplicationContext.CacheFuzzyMatches) { CommandPairManager.AddCommand(new CommandPair { Command = matchingFileName, Path = files[0] }); } //the matches for fuzzy searching are not cached RunProcess(files); } }
private void FindIt(string inputPath, string exeFileName, bool hasExtension) { if (launched) { return; } if (!inputPath.EndsWith(@"\")) { inputPath += @"\"; } if (hasFixedDepth) { //check depth int length = inputPath.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Length; int current = length - currentRootDepth; if (current > depth) { if (hasRunInDebugMode) { Console.WriteLine("Bailing out of {0} due to depth restriction", inputPath); } return; } } string[] files; if (hasExtension) { //user is looking for specific file files = Directory.GetFiles(inputPath, exeFileName); if (files.Length > 0) { RunProcess(files); CommandPairManager.AddCommand(new CommandPair { Command = exeFileName, Path = files[0] }); return; } } else { //search with all extensions foreach (string ext in ApplicationContext.Extensions) { files = Directory.GetFiles(inputPath, exeFileName + "." + ext); if (files.Length > 0) { RunProcess(files); CommandPairManager.AddCommand(new CommandPair { Command = exeFileName, Path = files[0] }); return; } } } string[] directories = Directory.GetDirectories(inputPath); foreach (string d in directories) { FindIt(d, exeFileName, hasExtension); } }