[RESOLVED]ASP.net 2.0 appending to a text file
i am trying to append to a log file. i ca create the file and write but the next time it will overwrite the last everything in the file.
Dim sdate As DateTime = DateTime.Now.ToShortDateString()
Dim stime As DateTime = DateTime.Now.ToShortTimeString()
Dim TextFile As New StreamWriter("C:\jetpaytool" & Format(sdate, "yyyyMMdd") & ".log")
TextFile.WriteLine(Format(sdate, "yyyyMMdd") & " " & Format(stime, "HH:MM") & " " & "auth release " & GridView1.Rows.Count.ToString & " Rows " & TextBox1.Text & " " & TextBox2.Text & " " & TextBox3.Text)
TextFile.Close()
thanks in advance
Re: ASP.net 2.0 appending to a text file
Moving your thread to the ASP.NET forum from the ASP forum.
Re: ASP.net 2.0 appending to a text file
You can use System.IO.File.AppendText.
Re: ASP.net 2.0 appending to a text file
thanks mendhak for moving my post to the right fourm
but i can not import System.IO.File.AppendText. there must be a referance that i need to add but i have only been using asp.net for 8 days
Re: ASP.net 2.0 appending to a text file
found this link in another post
http://aspnet.4guysfromrolla.com/art...72303-1.2.aspx
changed code to this and it works fine
Dim sdate As DateTime = DateTime.Now.ToShortDateString()
Dim stime As DateTime = DateTime.Now.ToShortTimeString()
Dim objStreamWriter As StreamWriter
objStreamWriter = File.AppendText("C:\jetpaytool" & Format(sdate, "yyyyMMdd") & ".log")
objStreamWriter.WriteLine(Format(sdate, "yyyyMMdd") & " " & Format(stime, "HH:MM") & " " & "auth release " & GridView1.Rows.Count.ToString & " Rows " & TextBox1.Text & " " & TextBox2.Text & " " & TextBox3.Text)
objStreamWriter.Close()
thanks for all of your help
[RESOLVED]ASP.net 2.0 appending to a text file
trying to mark as resolved