I have a comma delimited text file from which I'm reading. After I work the contents of each line & determine it's not a blank line, I write that line into a new text file. So the new file is the same as the original, except any blank lines have been removed.
My problem is that there is always a blank line at the end of the new file. The program that uses this new text file raises an error if there is a trailing blank line.
My code:
Sample data:
Thanks so much in advance for your guidance.
Bryant Farley
"The Dude Abides
My problem is that there is always a blank line at the end of the new file. The program that uses this new text file raises an error if there is a trailing blank line.
My code:
Code:
Dim strInvLines() As String = {}
Dim sr As New StreamReader(strInputFileName)
Dim fileText As String = sr.ReadToEnd()
sr.Close()
strInvLines = Split(fileText, vbCrLf)
Dim fs As New FileStream(Path.Combine(My.Settings.OutputDirectory, strInputFileName), FileMode.Create)
Dim sw As New StreamWriter(fs)
For Each line As String In strInvLines
If line.Length > 0 Then
sw.WriteLine(line)
End If
Next
sw.Close()
fs.Close()
Sample data:
Code:
20080523,0010079,RG,1,,BFE694200020035100,+,0144,.,45,+,002,00,+,0000288,.,89
20080620,0010079,RG,1,,BFE694200020035100,+,0144,.,45,+,006,00,+,0000866,.,67
20080627,0010079,RG,1,,BFE694200020035100,+,0144,.,44,+,005,00,+,0000722,.,22
Thanks so much in advance for your guidance.
Bryant Farley
"The Dude Abides