Skip to main content

Posts

Showing posts from August, 2010

Open and read content of a text file

OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Title = "Open a text file"; openDlg.FileName = ""; openDlg.Filter = "All Files|*.*"; string sFileName = ""; if (openDlg.ShowDialog() != DialogResult.Cancel) { sFileName = openDlg.FileName; StreamReader sr = new StreamReader(sFileName); string sContent = sr.ReadToEnd(); sr.Close(); sr = null; } openDlg = null;