Question:You are currently in the process of creating an application that reads binary information from a
file.
You need to ensure that the only the first kilobyte of data is retrieved.
What should you do? - (VB.NET) 

A Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim bs As New BufferedStream(fs)
Dim bytes As Byte() = New Byte(1022) {}
bs.Read(bytes, 0, bytes.Length)
bs.Close()
For i As Integer = 0 To bytes.Length - 2
Console.WriteLine("{0} : {1}", I, bytes(i__1))
Next 

B Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim bytes As Byte() = New Byte(1022) {}
fs.Read(bytes, 0, bytes.Length)
fs.Close()
For i As Integer = 0 To bytes.Length - 2
Console.WriteLine("{0} : {1}", I, bytes(i__1))
Next 

C Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim bs As New BufferedStream(fs)
Dim bytes As Byte() = New Byte(1022) {}
bytes = bs.ReadAllBytes(0, 1023)
bs.Close()
For i As Integer = 0 To bytes.Length - 2
Console.WriteLine("{0} : {1}", I, bytes(i__1))
Next 

D Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim bs As New BufferedStream(fs)
Dim bytes As Byte() = New Byte(1022) {}
bs.Read(bytes)
bs.Close()
For i As Integer = 0 To bytes.Length - 2
Console.WriteLine("{0} : {1}", I, bytes(i__1))
Next 

+ Answer
+ Report
Total Preview: 1832

Copyright © 2024. Powered by Intellect Software Ltd