Results 1 to 6 of 6

Thread: [RESOLVED]ASP.net 2.0 appending to a text file

  1. #1

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    Resolved [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
    Last edited by computerguy46; Jul 15th, 2008 at 06:54 PM. Reason: resolved

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: ASP.net 2.0 appending to a text file

    Moving your thread to the ASP.NET forum from the ASP forum.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: ASP.net 2.0 appending to a text file

    You can use System.IO.File.AppendText.

  4. #4

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    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

  5. #5

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    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

  6. #6

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    Resolved [RESOLVED]ASP.net 2.0 appending to a text file

    trying to mark as resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width