Public Class Form1
Private FileData As String = ""
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using ofd As New OpenFileDialog
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Try
FileData = My.Computer.FileSystem.ReadAllText(ofd.FileName)
txtFile.Text = ofd.FileName
RichTextBox1.Text = FileData
Catch ex As Exception
MessageBox.Show("File: " & ofd.FileName & vbCrLf & vbCrLf & ex.ToString, "Error Loadin File", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Using
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RichTextBox1.Text = FileData
End Sub
End Class
|