Created
May 6, 2012 17:25
-
-
Save zby/2623391 to your computer and use it in GitHub Desktop.
writing to a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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