Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Write & append messages to text file in Script t t

Author  Topic 

Harris00
Starting Member

19 Posts

Posted - 2009-05-08 : 11:07:41
Hello

I am using Streamwriter as below but it writes only the last message instead of appending to the file?
I am doing this in script task of SSIS.

Using writer As StreamWriter = New StreamWriter("C:\STExceptionLog.txt")

writer.WriteLine()
writer.Write(ex.ToString)

writer.Flush()
writer.Close()
End Using

how could i add and append log messages to the text file in Script task?

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2009-05-08 : 11:54:20
[code]
Using writer As StreamWriter = New StreamWriter("C:\STExceptionLog.txt", True)

writer.WriteLine("Blah blah")

writer.Flush()
writer.Close()
End Using

or

Dim sw As StreamWriter

If File.Exists("C:\STExceptionLog.txt") Then
sw = New StreamWriter("C:\STExceptionLog.txt", True) 'True for appending
sw.WriteLine("Blah blah")
sw.Flush()
sw.Close()
End If
[/code]
Go to Top of Page

Harris00
Starting Member

19 Posts

Posted - 2009-05-08 : 13:08:06
Thanks...
Go to Top of Page
   

- Advertisement -