Reading a text file using OpenFileDialog in windows forms
Here’s one way: Stream myStream = null; OpenFileDialog theDialog = new OpenFileDialog(); theDialog.Title = “Open Text File”; theDialog.Filter = “TXT files|*.txt”; theDialog.InitialDirectory = @”C:\”; if (theDialog.ShowDialog() == DialogResult.OK) { try { if ((myStream = theDialog.OpenFile()) != null) { using (myStream) { // Insert code to read the stream here. } } } catch (Exception ex) … Read more