Results 1 to 7 of 7

Thread: add to end of .txt

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    16

    add to end of .txt

    I need to add a way to add some text to the end of a text file from VB.NET.

  2. #2
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: add to end of .txt

    http://www.vbforums.com/showthread.php?t=4004698

    Post #18 should be close to what you want. The rest of the details (opening a stream and such) are scattered throghout the rest of the thread.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    16

    Re: add to end of .txt

    thread not found?

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: add to end of .txt

    In 2005 you can do

    VB Code:
    1. My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\file.txt", "AAA", True)

    And it will append to the end of a file

    If you arent using 2005 then please change your thread title to include version number

  5. #5
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: add to end of .txt

    VB Code:
    1. Dim str As String = "Banana Banana Terecotta Banana Terecotta Terecotta Pie"
    2.         Dim ioOut As New IO.StreamWriter("C:\SOAD.txt", True)
    3.  
    4.         ioOut.WriteLine(str)
    5.         ioOut.Flush()
    Last edited by sevenhalo; Apr 20th, 2006 at 01:59 PM.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    16

    Re: add to end of .txt

    aha i was missing the ,true thats why

  7. #7
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,284

    Re: add to end of .txt

    Quote Originally Posted by sevenhalo
    VB Code:
    1. Dim str As String = "Banana Banana Terecotta Banana Terecotta Terecotta Pie"
    2.         Dim ioOut As New IO.StreamWriter("C:\SOAD.txt", True)
    3.  
    4.         ioOut.WriteLine(str)
    5.         ioOut.Flush()
    ioOut.Close() call's it's own Flush() method and releases the dependence on the file, which imo is a better way of handling files

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