Examples

if (openFileDialog1.ShowDialog() == true)
{
// Open the selected file to read.
System.IO.Stream fileStream = openFileDialog1.SelectedFile.OpenRead();
using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
{
// Read the first line from the file and write it the textbox.
tbResults.Text = reader.ReadLine();
}
fileStream.Close();
}

If (openFileDialog1.ShowDialog = True) Then
'Open the selected file to read.
Dim fileStream As System.IO.Stream = openFileDialog1.SelectedFile.OpenRead
Using reader As New System.IO.StreamReader(fileStream)
' Read the first line from the file and write it to the text box.
tbResults.Text = reader.ReadLine
End Using
fileStream.Close()
End If