Question:You are in the process of creating a new application.
This new application has to be able to read all data from a text file.
What should you do? - (VB.NET) 

A Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim sr As New StreamReader(fs)
Dim data As String = sr.ReadToEnd()
sr.Close()
Console.WriteLine(data) 

B Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim data As String = sr.ReadToEnd()
fs.Close()
Console.WriteLine(data) 

C Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim data As New StringBuilder()
Dim data As String
While sr.Peek() > -1
data += sr.ReadLine()
End While
sr.Close()
Console.WriteLine(data) 

D Use the following code:
Dim fs As New FileStream("C:\file.txt", FileMode.Open)
Dim sr As New StreamReader(fs)
Dim data As New StringBuilder()
While sr.Peek() > -1
data.Append(sr.ReadLine())
End While
sr.Close()
Console.WriteLine(data.ToString()) 

+ Answer
+ Report
Total Preview: 970

Copyright © 2024. Powered by Intellect Software Ltd