I have a simple form with two textboxes, I want Textbox1
to write to a file named C:\VALUE1.txt
and Textbox2
to write its value to a file named C:\VALUE2.txt
Any text that is already in the text file MUST be over written.
I have a simple form with two textboxes, I want Textbox1
to write to a file named C:\VALUE1.txt
and Textbox2
to write its value to a file named C:\VALUE2.txt
Any text that is already in the text file MUST be over written.
Have a look at the
System.IO
andSystem.Text
namespaces, in particular theStreamWriter
object.It's worth being familiar with both methods:
1) In VB.Net you have the quick and easy My.Computer.FileSystem.WriteAllText option:
2) Or else you can go the "long" way round and use the StreamWriter object. Create one as follows - set false in the constructor tells it you don't want to append:
then write text to the file as follows: