Click here to Skip to main content
15,877,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I wrote the below code for saving data in a text file
Dim FILE_NAME As String = "C:\Application\Myfile.txt"

               If System.IO.File.Exists(FILE_NAME) = True Then

                   Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

                   MsgBox("Text written to file")


                   MsgBox("File Does Not Exist")

               End If

it's running fine, but the problem is when i enter the first value it's saving but for the second value it's overwriting the first one.
but i want to save all the values one after the other

Please tell me what to do

1 solution

Dim objWriter As New System.IO.StreamWriter(FILE_NAME, true)

true means append if the file Exists.
Share this answer
[no name] 23-May-13 2:21am    
can you tell me how to give a new line for this in the notepad..
MuhammadUSman1 23-May-13 2:39am    
if you want to write/put new line use

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900