private static void RunOptionsAndReturnExitCode(CommandLineOptions opts) { var configuration = new ConfigurationBuilder() .SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location)) .AddJsonFile($"appsettings.json", true, true) .AddEnvironmentVariables() .Build(); var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(builder => { builder .AddConfiguration(configuration.GetSection("Logging")) .AddConsole(); }); var serviceProvider = serviceCollection.BuildServiceProvider(); IReporter reporter = opts.Reporter switch { Reporter.PlainText => new PlainTextReporter(opts.Output ?? Path.Combine(Directory.GetCurrentDirectory(), $"report-{DateTime.Now:yyyyMMddHHmmss}.csv")), _ => new ConsoleReporter() }; var iteration = new StackBasedIteration(serviceProvider.GetService <ILogger <StackBasedIteration> >(), reporter, configuration.GetSection("Parsing:Excludes").Get <List <string> >()); opts.Directories.ToList().ForEach(x => iteration.TraverseTree(x)); }
private void OK_Button_Click(object sender, RoutedEventArgs e) { var instance = new StackBasedIteration(); if (_folderDirectory != null) { //TODO: Add filename rather than just Temp.tsv in user's temp directory StackBasedIteration.TraverseTree(_folderDirectory); string tstr = "See 'Temp.tsv' file in user's temp folder using Windows key + R and type '%temp%' (hit Enter)"; System.Windows.MessageBox.Show(tstr); Application.Current.Shutdown(); } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); // How to iterate through a directory tree RecursiveFileSearch.Run(); StackBasedIteration.Run(@"C:\SAJ"); FileSysInfo.Run(); CreateFileOrFolder.Run(); SimpleFileCopy.Run(); SimpleFileMove.Run(); SimpleFileDelete.Run(); WriteTextFile.Run(); ReadFromFile.Run(); // How to create a key in the registry RegistryTest.Run(); }