Append Text with StreamWriter VB.Net

~OSD~ 2,201 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()  
                    '  
Developer technologies | VB
Developer technologies | Visual Studio | Other
{count} votes

Accepted answer
  1. LesHay 7,141 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.