Add, Delete Text

PureSc0pe

Well-known member
Joined
Mar 17, 2004
Messages
161
Location
Arizona
I know I need to use StreamWriter, but how would I go about creating vb code to add and delete a whole line of text from a text document. You enter the text into a TextBox and Click the button to enter it.
 
Use ReadLine, in a loop, have an if statement in the loop. If the current line <> specified line, then add to string. Then write out this string.

So basically u break the txtfile down line by line then add the lines that are wanted to another string - which you output.
 
For adding the contents of a textbox to the end of a file, open the file for Append mode.
For adding the text anywhere besides the end of the file, youll need to do as Jay1b mentioned and Readline from the file into a string, and then Write the string into a new file. :)
 
I am having trouble with this one...Can you start me off with some Code? I want to write to the end of the textfile.
 
To open the file in append mode create a new StreamWriter object, and as a second argument pass in true which will tell the stream writer that you want to write to the end of the file.
 
Back
Top