private async void StatsExecuteBtnClick(object sender, EventArgs e) { if (FileRadio.Checked && File.Exists(FilePathTxb.Text)) { WdTools = WdTools ?? new WordTools(); int result = await WdTools.PrintDocxStats(FilePathTxb.Text, this.statsXpathChkb.Checked, this.statsSectionsChkb.Checked, this.statsFooterHeadersChkb.Checked); } else { if (!FileRadio.Checked && Directory.Exists(FilePathTxb.Text)) { //TODO implement Program.GetFiles(string dir, string pattern, ref List<string> files) string[] Files; Files = RecursiveChkb.Checked ? Directory.GetFiles(FilePathTxb.Text, "*.docx", SearchOption.AllDirectories) : Directory.GetFiles(FilePathTxb.Text, "*.docx"); foreach (string FileName in Files) { WdTools = WdTools ?? new WordTools(); int result = await WdTools.PrintDocxStats(FileName, this.statsXpathChkb.Checked, this.statsSectionsChkb.Checked, this.statsFooterHeadersChkb.Checked); } } } Console.WriteLine("Done."); }