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;
Coding is one of my job from 2001. I have written codes for many projects but I cannot remember all of them. I hope this blog help me do that.