imports System imports Microsoft.VisualBasic Imports System.IO imports System.Collections Imports cc = Microsoft.VisualBasic.ControlChars public module MyModule Sub Main Dim strOutput as String Dim strPath as string = "C:\Documents and Settings\DGarlen\Desktop\CodeSnippetCompiler\SavedSnippets\SampleData\" Dim strFile as string = "ReadMe.Txt" strOutput = Read_Text_File(strPath & strFile) Console.WriteLine("*************") Console.WriteLine(strOutput) Console.WriteLine("*************") Console.Write("Press Enter to Continue") Console.ReadLine() End Sub Private Function Read_Text_File(byVal strFileName as String) as String ' Reads Textfile and copies into a Multiline Textbox named txtTextBlock Dim strExtendedFileName As String = strFileName 'strExtendedFileName = Server.MapPath(strFileName) Dim strTextBlock as string Try 'http://www.vbwm.com/articles/builder/viewer.asp?ArticleID=15 Dim fs As New _ System.IO.FileStream(strExtendedFileName, _ System.IO.FileMode.Open, _ System.IO.FileAccess.Read, _ System.IO.FileShare.Read) ' create a stream reader attach the file stream to it Dim sr As New System.IO.StreamReader(fs) 'Dim strLine As String = sr.ReadToEnd() Dim strLine As String strLine = sr.ReadLine() Do While strLine <> Nothing strLine = sr.ReadLine() strTextBlock = strTextBlock & strLine & cc.NewLine Loop sr.Close() fs.Close() Catch exp As Exception strTextBlock = "An error in loading file. The error is:" _ + cc.NewLine + exp.ToString() + cc.NewLine End Try Return strTextBlock End Function end module