Hi folks. I'm having some problem here. I have a list of files to read and have to append them all to one unique file. the problem is that when i open the first file to read. I read the first line and discard it. when i read the second line, its empty ! but it is not in the original file. what im doing wrong ? tks for the help

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGera.Click
        Dim QtdPapeis As Integer
        Dim I As Integer
        Dim oWrite As System.IO.StreamWriter
        Dim oRead As System.IO.StreamReader
        Dim caminho As String

        oWrite = IO.File.CreateText("c:\ibov\carga.txt")
        QtdPapeis = PF.SecurityCount() - 1
        For I = 0 To QtdPapeis
            caminho = "c:\ibov\" & PF.Security(I).GetSymbol & ".txt"
            oRead = New System.IO.StreamReader(caminho)
            GeraCargaTabelaQuotes(oRead, oWrite)
            oRead.Dispose()
        Next
        oWrite.Dispose()
    End Sub

Public Sub GeraCargaTabelaQuotes(ByVal arq_origem As System.IO.StreamReader, ByVal arq_destino As System.IO.StreamWriter)
        Dim linhaAtual, linhaescrever, cod, desc, periodo, data, hora, open, high, low, close, volume, interest As String
        Dim strArray() As String
        linhaAtual = arq_origem.ReadLine() 'pula a 1a linha
        linhaAtual = arq_origem.ReadLine()
        While (Not arq_origem.EndOfStream)
            strArray = linhaAtual.Split(",")
            cod = strArray(1)
            desc = strArray(2)
            periodo = strArray(3)
            data = strArray(4).Substring(0, 4) & "-" & strArray(4).Substring(4, 2) & "-" & strArray(4).Substring(6, 2)
            hora = strArray(5)
            open = strArray(6)
            high = strArray(7)
            low = strArray(8)
            close = strArray(9)
            volume = strArray(10)
            interest = strArray(11)
            linhaescrever = cod & ";" & desc & ";" & periodo & ";" & data & ";" & hora & ";" & open & ";" & high & ";" & low & ";" & close & ";" & volume & ";" & interest
            arq_destino.WriteLine(linhaescrever)
            linhaAtual = arq_origem.ReadLine()
        End While

    End Sub

it seams that is something to do with the file im using. i tried with other file and worked. do you figure out whats going on ?

content of the file that worked:
line 1
line 2

content of the file that is not working:
<TICKER>,<NAME>,<PER>,<DATE>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>,<OPENINT>
TGMA3,TEGMA ON,D,20070703,000000,20.14018,20.83202,20.14018,20.37079,2538500,3722

the second line returns empty !

I found out that each line is terminated by a "?". how can I do VB understand that this is my end of line ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.