read/write text files

ilias_adm13

Member
Joined
Feb 27, 2008
Messages
7
Programming Experience
5-10
hey ,
i want to save my textbox's data into a text file . i want to be able too to load a textfile into my text box . how am i going to do that ?
 
Reading and writing files from textbox to file and vice versa

a.
You can use the System.IO.File object to read the file into a text box.

System.IO.File.WriteAllText(path to file as a string, TextBox1.Text)

b. You can use the StreamReader object get all of the file's information and then enter into textbox


Dim oRead As System.IO.StreamReader
oRead = System.IO.File.OpenText(path to file as string)
TextBox1.Text = oRead.ReadToEnd()

Piaget
 
how did it help in 2008? i thought it doesnt work in vb9,

in case it gives u any problems, u can also use the following:

VB.NET:
my.computer.filesystem.writealltext(filename, textbox1.text, false)

and for loading the same text:
VB.NET:
my.computer.filesystem.readalltext(filename)

it's shorter and cleaner but don't use this with a richtextbox control if it has any images... ;).
 
Back
Top