shiva said:
Thank you for the feedback Sir. Well, i am just trying to print
a 30MB file
and its shaky. It gets hogged sometimes amd prints sometimes as
if it works
when we have luck. Unless or otherwise something is wrong with
the following
code. There is lot more transactions to do than just printing,
but it is
skaky right here when printing.
Private Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Open a file for reading
Dim FILENAME As String
Dim FileContents As String
Dim iCount As Integer
iCount = 1
FILENAME = "c:\\Filereader\\File1.txt"
Try
'Get a StreamReader class that can be used to read
the file
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(FILENAME)
'Read Line By Line
While True
FileContents = CType(objStreamReader.ReadLine,
String)
ReadLine returns a string already, so there is no reason to
re-caste it.
If Not FileContents = Nothing Then
Response.Write(iCount & "Begin Line1" &
"<br>")
Response.Write(FileContents)
Response.Write("<br>" & iCount & "End Line1"
& "<br>")
iCount = iCount + 1
'lblRawOutput.Text &= FileContents & vbCrLf
Else : Exit While
End If
End While
It doesn't look like your speed issues are due to the way you are
working with the files, but rather with what you are doing with
all the data.
What is this Response object you are working with? I'm assuming
it's something like a web response. If this is the case then it
can take quite a while to send the 30 MB of data via the network.
Even on a local network it can take a while depending on network
configuration and current traffic loads.
Also you have
'lblRawOutput.Text &= FileContents & vbCrLf
commented out. However, if your tests were done with this
uncommented it could have a drastic performance hit for large
files, as the larger a string gets, the longer it takes to
concatenate more data on to the end of it.
Andrew Faust