phillip.hess@dot.gov
Member
- Joined
- Nov 9, 2009
- Messages
- 16
- Programming Experience
- Beginner
Greetings
I have situation where I read a source file, create a temporary text file of the source and modify the temp file. If I open the file twice it appends to the end of the first temp file even though Ihave StreamWriter append set to false. Only if I close and reopen my application does it not append. It like there is buffer or something not getting cleared. Below is the syntax I'm using.
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Using objReader As New IO.StreamReader(OpenFileDialog1.FileName)
While Not objReader.EndOfStream
list.Add(objReader.ReadLine)
End While
End Using
Using objWriter As New StreamWriter("C:\Temp\GeoRptTemp.txt", False)
For Each s As String In list
If Not s = "" And s.Length > 40 Then
objWriter.WriteLine(s.Insert(40, strGap))
Else
objWriter.WriteLine(s)
End If
Next
objWriter.Close()
End Using
End If
Using objReader As New IO.StreamReader("C:\Temp\GeoRptTemp.txt", False)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
RichTextBoxPrintCtrl1.Font = New Font("Lucida Console", 10, FontStyle.Regular)
RichTextBoxPrintCtrl1.Text = TextLine
End Using
Any help would be apreciated.
I have situation where I read a source file, create a temporary text file of the source and modify the temp file. If I open the file twice it appends to the end of the first temp file even though Ihave StreamWriter append set to false. Only if I close and reopen my application does it not append. It like there is buffer or something not getting cleared. Below is the syntax I'm using.
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Using objReader As New IO.StreamReader(OpenFileDialog1.FileName)
While Not objReader.EndOfStream
list.Add(objReader.ReadLine)
End While
End Using
Using objWriter As New StreamWriter("C:\Temp\GeoRptTemp.txt", False)
For Each s As String In list
If Not s = "" And s.Length > 40 Then
objWriter.WriteLine(s.Insert(40, strGap))
Else
objWriter.WriteLine(s)
End If
Next
objWriter.Close()
End Using
End If
Using objReader As New IO.StreamReader("C:\Temp\GeoRptTemp.txt", False)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
RichTextBoxPrintCtrl1.Font = New Font("Lucida Console", 10, FontStyle.Regular)
RichTextBoxPrintCtrl1.Text = TextLine
End Using
Any help would be apreciated.