A
Arpan
A file can be read using only the StreamReader object like this:
Dim sReader As StreamReader
sReader = New StreamReader(Server.MapPath("File1.txt"))
While(sReader.Peek > -1)
Response.Write(sReader.ReadLine)
End While
as well as using the FileStream object along with the StreamReader
object like this:
Dim fStream As FileStream
Dim sReader As StreamReader
fStream = New FileStream(Server.MapPath("File1.txt"), FileMode.Open,
FileAccess.Read)
sReader = New StreamReader(fStream)
While(sReader.Peek > -1)
Response.Write(sReader.ReadLine)
End While
Now how do I decide which way to go when I want to read a file?
If I am not mistaken, the second way would involve additional overheads
as compared to the first way, isn't it?
Thanks,
Arpan
Dim sReader As StreamReader
sReader = New StreamReader(Server.MapPath("File1.txt"))
While(sReader.Peek > -1)
Response.Write(sReader.ReadLine)
End While
as well as using the FileStream object along with the StreamReader
object like this:
Dim fStream As FileStream
Dim sReader As StreamReader
fStream = New FileStream(Server.MapPath("File1.txt"), FileMode.Open,
FileAccess.Read)
sReader = New StreamReader(fStream)
While(sReader.Peek > -1)
Response.Write(sReader.ReadLine)
End While
Now how do I decide which way to go when I want to read a file?
If I am not mistaken, the second way would involve additional overheads
as compared to the first way, isn't it?
Thanks,
Arpan