streamreader problem

  • Thread starter Thread starter Kevin Vogler
  • Start date Start date
K

Kevin Vogler

I'm trying to read through a text file (15,000 lines) and do a replace on
each line. The stream reader says that I've reached the end of the file at
around 7500 lines and subsequent reads return nothing. What am I doing
wrong?
Thanks in advance.
Dim Fs As FileStream = New FileStream(filename, _
FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read)
Dim FSW As FileStream = New FileStream("C:\new.csv", FileMode.OpenOrCreate,
FileAccess.Write, FileShare.Write)
Dim sw As New StreamWriter(FSW)
Dim sr As New StreamReader(Fs)
Dim input As String = ""
Dim sl As String = ""

While (InlineAssignHelper(input, sr.ReadLine())) IsNot Nothing
sl = sl.Remove(0, 1).Replace(Chr(34) + Chr(44),
Chr(126)).Replace(Chr(44) + Chr(34), Chr(126)).Replace(Chr(34) + Chr(126),
Chr(126)).Replace(Chr(126) + Chr(34), Ch(126))
sw.WriteLine(sl)
End While



Kevin Vogler
 
Kevin said:
I'm trying to read through a text file (15,000 lines) and do a replace on
each line. The stream reader says that I've reached the end of the file at
around 7500 lines and subsequent reads return nothing. What am I doing
wrong?
Thanks in advance.
Dim Fs As FileStream = New FileStream(filename, _
FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read)
Dim FSW As FileStream = New FileStream("C:\new.csv", FileMode.OpenOrCreate,
FileAccess.Write, FileShare.Write)
Dim sw As New StreamWriter(FSW)
Dim sr As New StreamReader(Fs)
Dim input As String = ""
Dim sl As String = ""

While (InlineAssignHelper(input, sr.ReadLine())) IsNot Nothing
sl = sl.Remove(0, 1).Replace(Chr(34) + Chr(44),
Chr(126)).Replace(Chr(44) + Chr(34), Chr(126)).Replace(Chr(34) + Chr(126),
Chr(126)).Replace(Chr(126) + Chr(34), Ch(126))
sw.WriteLine(sl)
End While



Kevin Vogler

I think you left out the most important piece of the code. What is
InlineAssignHelper()?
 
Mike,

Thanks for the response.

I just figured it out. I was calling the readline twice in each loop.

Thanks for the interest.

Kevin Vogler
 
Back
Top