OpenFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) 'OpenFileDialog1.InitialDirectory = "C:Program Files" OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files(*.*)|*.*" OpenFileDialog1.FileName = "" OpenFileDialog1.FilterIndex = 1 'Check to see if the user clicked the open button If (OpenFileDialog1.ShowDialog() = DialogResult.OK) Then TextBox1.Text = OpenFileDialog1.FileName Try Using sr As New StreamReader(TextBox1.Text) Dim line As String line = sr.ReadToEnd() TextBox2.Text = line End Using Catch ex As Exception MessageBox.Show("The file could not be read:" & Environment.NewLine & ex.Message.ToString()) End Try Else 'MsgBox("You did not select a file!") End If
Last Updated on October 26, 2015