Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I've been googling this problem for a while and I can't find an answer, I'm writing a program that basically looks at a text file, reads a line, parses it out, and writes to another file. I'm VERY new and my knowledge is mostly self-taught, but I can't seem to get out of this one. It works for smaller files, but it appears to reach a limit in characters at some point because in a file of 900 lines, it stops writing about halfway through 800 and there are no errors, the program actually completes and the message box pops up.
here is the code, hopefully someone can help. I'm sure there are a lot of problems with how i wrote this.
Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
Dim IndexValues As String()
Dim TextPath As String = txtFilePath.Text.ToString
Dim TextFile As StreamReader
Dim FinalFile As StreamWriter
Dim GarbagePath As String()
Dim i As Integer
Dim ID As Integer = 1
If File.Exists(TextPath) Then
TextFile = File.OpenText(TextPath)
FinalFile = File.CreateText(TextPath & ".csv")
FinalFile.WriteLine("ID,Company Number,File Cabinet,Invoice Number,Supplier Code,Filename")
Do Until TextFile.Peek() = -1
IndexValues = TextFile.ReadLine().Split(",")
GarbagePath = IndexValues(IndexValues.GetUpperBound(0)).Split("")
For i = 0 To IndexValues.GetUpperBound(0)
IndexValues(i) = Replace(IndexValues(i), Chr(34), "")
GarbagePath(GarbagePath.GetUpperBound(0)) = Replace(GarbagePath(GarbagePath.GetUpperBound(0)), _
FinalFile.WriteLine(ID & "," & IndexValues(3) & "," & IndexValues(5) & "," & IndexValues(7) & "," & IndexValues(9) _
& "," & GarbagePath(GarbagePath.GetUpperBound(0)))
ID += 1