Click here to Skip to main content
15,849,328 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
VB
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)

                   objWriter.Write(fullPath)
                   objWriter.Close()
                   MsgBox("Text written to file")

               Else

                   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
Posted

1 solution

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

true means append if the file Exists.
 
Share this answer
 
Comments
[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
Environment.NewLine

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