hello guys

i have a question because in my I.O.File i use this to save the data in the listview in a c:\test.txt but the problem is that it only save one data and every time i click the save the previous data that i save is deleted and it change the new one that i save...and also when i click the remove in the listview it will also delete the data that save in the c:\test.txt and the format should like this

First name | lastname | address |
rae alanah new york
john smith los angeles

here the code that i did...

Dim myFile As String = "C:\test.txt" '//file location
        System.IO.File.WriteAllText(myFile, TextBox1.Text & " " & ComboBox1.Text & " " & TextBox4.Text & " " & ComboBox2.Text & " " & TextBox3.Text & " " & TextBox2.Text & " " & TextBox5.Text)

or you can also create new code base on ur understanding...

help me this is the first time i use the I.O file or file stream in vb.net because my crystal report does not detect my database that's why i need to do this...:'(

Edited 6 Years Ago by __avd: Added [code] tags.

Dim myFile As String = "C:\test.txt" '// file location.
        Dim myWriter As New IO.StreamWriter(myFile)
        For Each myItem As ListViewItem In ListView1.Items
            myWriter.WriteLine(myItem.Text & "|" & myItem.SubItems(1).Text & "|" & myItem.SubItems(2).Text)

once again thank u:) and the one that u p.m i'll send it..

oppss there is an error it conflict with my data source in but it's ok i already fix it just add some code..:) thanks

can someone give me a code to load the textfile in a listview????

fretje, I'll send you a private message since some details are needed.
Unless.... the following link might just provide that information.
Save/Load Listview Items + Subitems

Edited 6 Years Ago by codeorder: n/a

This question has already been answered. Start a new discussion instead.