ssis APPENDING TO A TEXT FILE

  • I HAD CREATED A FILE FROM THE SCRIPT TASK WHICH PROVIDES CORRECTLY TO APPEND TO THE FILE BUT I AM NOT ABLE TO APPEND THE LAST SET OF RECORDS I CREATED TO THE TOP OF THE fiLE

    --

    Public Sub Main()

    Dim errorInfo As String = ""

    Dim Contents As String = ""

    Dim s As String

    ' s = "d:\\resultsxml.txt" ' declare the folder and the file to write log

    Dim sReader As New StreamReader("d:\resultsxml.txt")

    s = "d:\resultsxml.txt"

    If File.Exists(s) Then

    Do Until sReader.Peek = -1

    Contents = Dts.Variables("srinath").Value.ToString()

    WriteVariableContents(s, Contents)

    Loop

    Else

    File.Create(s)

    End If

    End Sub

    Public Sub WriteVariableContents(ByVal filePath As String, ByVal contents As String)

    Dim objWriter As IO.StreamWriter

    objWriter = New IO.StreamWriter(filePath, True, Encoding.ASCII)

    objWriter.Write(contents)

    ' sMyfileData = sReader.ReadToEnd

    objWriter.Close()

    End Sub

    I WANT THE LAST APPENED COLUMN TO COME TO TOP!

  • I think if I'm understanding you correctly you have information that you want to append to the top of the file instead of at the end. I believe the only way for you to do this would be to either output that information first in your streamwriter or if thats not an option you can use the stringbuiler to insert the last column first in your content variable, prior to using the streamwriter to write the results of the variable

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply