streamreader problem

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
 
F

Family Tree Mike

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()?
 
K

Kevin Vogler

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top