private void btnBrowse_Click(object sender, EventArgs e) { openFileandRead(); } public void openFileandRead() { Stream myStream = null; OpenFileDialog Dialog = new OpenFileDialog(); Dialog.Title = "Open Text File"; Dialog.Filter = "TXT files|*.txt"; Dialog.Multiselect = true; //allows to select multiple files in openfiledialog if (Dialog.ShowDialog() == DialogResult.OK) { try { if ((myStream = Dialog.OpenFile()) != null) { using (myStream) { string[] filePaths = Directory.GetFiles(@"D:\TestTxtFiles", "*.txt", SearchOption.AllDirectories); foreach (string file in filePaths) { rtxtFile.AppendText(System.IO.File.ReadAllText(file)); Thread.Sleep(2000); } } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)