🔒 Closed Vb.net filehandling edit/update in console application

Status
Not open for further replies.

marleybob

Honorary Poster
Na coconfused na po ako. I want to replace the value sa txt file gamit ang arraylist then marereplace din yung data na nasa loob ng " txt file " , in short i want to edit the data. (1st) gumamit ako ng reader para ma add yung data sa Arraylist. (2nd) Gumamit ako ng "streamwriter" para ma edit o i overwrite lang yung specific data . kaya naghihingi ako ng input galing kay user kung anung id number ang iiedit niya. na update naman siya but ang problema ay nawala yung ibang data.

ITO original laman ng txt file : ex:
1, James , 200 , 24
2, Michael, 300, 10
AFter ma edit/update : ex:
2, Lebron James, 201, 23
 

Attachments

  • upload_2018-7-28_13-15-5.png
    upload_2018-7-28_13-15-5.png
    50.6 KB · Views: 0
  • upload_2018-7-28_13-15-44.png
    upload_2018-7-28_13-15-44.png
    44.5 KB · Views: 0
  • upload_2018-7-28_13-32-26.png
    upload_2018-7-28_13-32-26.png
    26.6 KB · Views: 0
  • upload_2018-7-28_13-33-14.png
    upload_2018-7-28_13-33-14.png
    26.8 KB · Views: 0
For every loop of idList, you create an instance of StreamWriter. StreamWriter, has this default behavior where it creates a file (if it does not exist) or overwrites a file (if it does exist).

Solution:
Using sw as StreamWriter = new StreamWriter(filePath, TRUE)
sw.WriteLine(line);
End Using
 
For every loop of idList, you create an instance of StreamWriter. StreamWriter, has this default behavior where it creates a file (if it does not exist) or overwrites a file (if it does exist).

Solution:
Using sw as StreamWriter = new StreamWriter(filePath, TRUE)
sw.WriteLine(line);
End Using
I already done it. okay na po salamat :) oo ganyan po ginawa ko kaso inalis ko yang true para ma overwrite.
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 554
    Views
  • 3
    Participants
Last reply from:
marleybob

Trending Topics

Online now

Members online
1,102
Guests online
1,742
Total visitors
2,844

Forum statistics

Threads
2,286,663
Posts
29,039,428
Members
1,217,114
Latest member
Tanjiro999
Back
Top