Link to Us

New with .net 2.0

Reading from a file:
label1.Text = My.Computer.FileSystem.ReadAllText("Myfile.txt")

Saving a file
My.Computer.FileSystem.WriteAllText(“Myfile.txt”,textbox1.text, true)

Without a path it saves the file in the same directory are the application.
In this case the bin/debug folder of my project
stream from the web
Stream from a network

  • Streams can be more than files
  • Create a new project
  • Add a button and a textbox
  • Set the textbox to multiline and the scrollbars to Both
  • Add this code to the top of the page:

Imports System.IO

  • Add this code to the button click event:

Dim myRequest As WebRequest
myRequest = WebRequest.Create("")
Dim theResponse As WebResponse = myRequest.GetResponse()
Dim responseStream As Stream = theResponse.GetResponseStream()
Dim reader As New StreamReader(responseStream)

The Stringbuilder class provides a more efficient way to concatenate strings. Adding one string to another actually causes a new string to be created.
Add this code to the top of the page:
Imports System.Text

Add this code below your previous code in the button click event:


Dim sb As New StringBuilder
Loop While Not reader.ReadLine Is Nothing
TextBox2.Text = sb.ToString()

stream from a network