Skip to content

Instantly share code, notes, and snippets.

@zby
Created May 6, 2012 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zby/2623391 to your computer and use it in GitHub Desktop.
Save zby/2623391 to your computer and use it in GitHub Desktop.
writing to a file
Import System
Import System.IO
Class Test
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("TestFile.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
Console.WriteLine(line)
Loop Until line Is Nothing
sr.Close
Catch E As FileNotFoundException
' Let the user know what went wrong
Console.WriteLine("The file could not be found:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment