Append Text with StreamWriter VB.Net

~OSD~ 2,126 Reputation points
2022-09-29T11:09:14.807+00:00

Hi,

I am writing text to a text file using StreamWriter, it do the work as expected but I am wondering if the text can be Appended instead of overwritting?

'Save value into text file  
                    '  
                    Dim objWriter As New System.IO.StreamWriter(TxtFile, False)  
                    objWriter.WriteLine(TxtFile.ToString)  
                    objWriter.Close()  
                    '  
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,631 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,580 questions
{count} votes

Accepted answer
  1. LesHay 7,126 Reputation points
    2022-09-29T14:05:43.777+00:00

    Hi
    Try changing the second parameter to True. While you are typing the code for that line, when you add the comma after 'txtfile', then when you press space, you should get a pop up balloon with helpful information. In this case you will likely get 3 of 8, if you use the little down arrow onto 4 of 8, red the help text and maybe you will see what you want.

    Dim objWriter As New System.IO.StreamWriter(TxtFile, True)  
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful