The document discusses four applications and reading a file. It provides code in Visual Basic for opening a selected file, reading it byte by byte, and displaying the text in a text box. The code declares variables to store the file stream, buffer, number of bytes to read, number read so far, and uses a loop to continuously read portions of the file and append it to a string builder until complete.
The document discusses four applications and reading a file. It provides code in Visual Basic for opening a selected file, reading it byte by byte, and displaying the text in a text box. The code declares variables to store the file stream, buffer, number of bytes to read, number read so far, and uses a loop to continuously read portions of the file and append it to a string builder until complete.
The document discusses four applications and reading a file. It provides code in Visual Basic for opening a selected file, reading it byte by byte, and displaying the text in a text box. The code declares variables to store the file stream, buffer, number of bytes to read, number read so far, and uses a loop to continuously read portions of the file and append it to a string builder until complete.
Private Sub btnabrir_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnabrir.Click ofd1.ShowDialog() Dim str As System.IO.Stream str = ofd1.OpenFile Dim txt As New System.Text.StringBuilder Dim buffer(1000) As Byte Dim numbytestoread As Integer = CInt(str.Length) Dim numbytesread As Integer = 0 Dim n As Integer While (numbytestoread > 0) n = str.Read(buffer, 0, 1000) Console.WriteLine(n.ToString & " Leer ") If n = 0 Then Exit While End If Dim i As Integer For i = 0 To n txt.Append(Chr(buffer(i))) Next numbytesread += n numbytestoread -= n End While str.Close() txtarchivo.Text = txt.ToString End Sub