Colleagues,
I am new to StreamWriter class, trying to figure out what am I doing wrong (if anything).
The goal/task is: open the existing file (tcFileIn), read the contents and append iCnt times the contents of that lsBlock text to the existing tcFileOut.
Note: File tcOutFile is not empty, it has some header info in it.
But instead of appending, StreamWriter overwrites that existing text in the tcFileOut (with that iCnt times the lsBlock).
Here's the code:
What am I missing?
OR
Is it "feature, not a bug" of the StreamWriter that it has no "Append" option/setting?
TIA!
Regards,
Ilya
I am new to StreamWriter class, trying to figure out what am I doing wrong (if anything).
The goal/task is: open the existing file (tcFileIn), read the contents and append iCnt times the contents of that lsBlock text to the existing tcFileOut.
Note: File tcOutFile is not empty, it has some header info in it.
But instead of appending, StreamWriter overwrites that existing text in the tcFileOut (with that iCnt times the lsBlock).
Here's the code:
Code:
Dim loStreamReader As StreamReader = New StreamReader(tcFileIn)
Dim iCnt As Long = 0, lsBlock As String = loStreamReader.ReadToEnd()
' Srteam Reader did the job - StreamReader can go!
loStreamReader.Close()
loStreamReader.Dispose()
Dim loStreamWriter As New StreamWriter(tcFileOut)
For iCnt = 1 To tiChkCnt
loStreamWriter.Write(lsBlock & vbCrLf)
Next
loStreamWriter.Flush()
loStreamWriter.Close()
loStreamWriter.Dispose()
OR
Is it "feature, not a bug" of the StreamWriter that it has no "Append" option/setting?
TIA!
Regards,
Ilya