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...:'(

Recommended Answers

All 5 Replies

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)
        Next
        myWriter.Close()

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????

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.