private void importSortTextFileLinks() { cFile oFile = new cFile("FilesLoaded"); try { string startupPath = Application.StartupPath; using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "Open a folder which contains the xml output"; // dialog.ShowNewFolderButton = false; // dialog.RootFolder = Environment.SpecialFolder.MyComputer; if (dialog.ShowDialog() == DialogResult.OK) { string folder = dialog.SelectedPath; lblOutput.Text = dialog.SelectedPath; foreach (string fileName in Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories)) { oTool.ExportedLinkPath = "Input.txt"; List <string> sUrls = oTool.GetLinksFromFile(fileName); oTool.WriteLinks(sUrls); oTool.AddUrlList(sUrls); oFile.Write(fileName); //SQLGenerator.GenerateSQLTransactions(Path.GetFullPath(fileName)); } oTool.Sort(); } } //using (OpenFileDialog dialog = new OpenFileDialog()) //{ // dialog.Filter = "xml files (*.xml)|*.xml"; // dialog.Multiselect = false; // dialog.InitialDirectory = "."; // dialog.Title = "Select file (only in XML format)"; // if (dialog.ShowDialog() == DialogResult.OK) // { // SQLGenerator.GenerateSQLTransactions(Application.StartupPath + Settings.Default.xmlFile); // } //} lblOutput.Text = "done"; } catch (Exception exc) { MessageBox.Show("Import failed because " + exc.Message + " , please try again later."); } }
private Task ProcessFile(string fileName) { cFile oFile = new cFile("log"); // use await here, like so Task task = new Task(() => { try { cUrlTool voTool = new cUrlTool(); voTool.GetLinksFromFile(fileName); voTool.WriteLinks(); } catch (Exception ex) { oFile.Write(ex.Message); } }); //Task<List<String>> voTask = new Task<List<String>>(() => GetLinksFromFile(vsFilepath)); return(task); }