How can i set Textbox1.text equal to the conents of file.txt?

Recommended Answers

All 3 Replies

You need to read the file first n then store the content in the textbox1.text.hope you are familia with file operations.

Use methods of System.IO.File class.

If System.IO.File.ReadAllText("file.txt") = TextBox1.Text Then
  'Put your code
End If

How can i set Textbox1.text equal to the conents of file.txt?

'to read text from a plain text file we have 
My.Computer.filesystem.ReadAllText

'to read a binary file we have 

my.computer.filesystem.ReadAllBytes


'Answer to your question , although your questions have multiple
'answers

textbox1.text = My.Computer.Filesystem.ReadAllText("Absolute File Path")
'like C:\testfile.txt

'to save the contents of textbox to a file
my.computer.filesystem.WriteAllText("File Path",textbox1.text,false)
'last parameter false for dont append
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.