StreamWriter Is Overriding Already Written Items in File

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

StreamWriter Is Overriding Already Written Items in File

 
0
  #1
Mar 31st, 2009
Hello everyone. I have a small problem. I have a Streamwriter writing things to a file. But when i write more than one thing, the previous item gets overwritten. I.E. Write 1111, Write 2222. 1111 gets replaced by 2222.

Here is some of my code:

  1. Dim fileOut As New IO.StreamWriter(fileName)
  2.  
  3. fileOut.WriteLine(userId)
  4.  
  5. fileOut.Close()

userId is a String
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: StreamWriter Is Overriding Already Written Items in File

 
0
  #2
Mar 31st, 2009
You have to create StreamWriter in the append mode
  1. Dim fileOut As New System.IO.StreamWriter(fileName, True)
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: StreamWriter Is Overriding Already Written Items in File

 
0
  #3
Mar 31st, 2009
It's not appending yet. I added to true to the end, but that didn't do anything. It's still overwriting
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: StreamWriter Is Overriding Already Written Items in File

 
0
  #4
Mar 31st, 2009
Ah Nevermind. Thank you so much!

How can i make a multi column listbox? I added the true under properties for multi column, and added the width, but don't see anything. I wanted to make a column for user Names and another for User Ids.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: StreamWriter Is Overriding Already Written Items in File

 
0
  #5
Mar 31st, 2009
Originally Posted by jhonnyboy View Post
Ah Nevermind. Thank you so much!

How can i make a multi column listbox? I added the true under properties for multi column, and added the width, but don't see anything. I wanted to make a column for user Names and another for User Ids.
It appends now? Great. Please mark the thread solved and re-post that new question in a new thread, thanks.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: StreamWriter Is Overriding Already Written Items in File

 
0
  #6
Mar 31st, 2009
You got it
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC