Thank you for viewing the source code to
MySource.aspx.
If you see any bugs in this code, please
Let me know! I will be
happy to correct the problem.
Imports System.IO
Partial Class MySource
Inherits System.Web.UI.Page
Private relPath As String = "Source/"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Request.QueryString("File") Is Nothing Then
Call DisplaySource(Request.QueryString("File"))
End If
End Sub
Private Sub DisplaySource(ByVal strSourceFile As String)
' Me.ltChar.Text = ""
Try
Dim path As String = Server.MapPath(relPath) '& "\"
Me.lblFileName.Text = strSourceFile
'declaring a FileStream to open the file named file.doc with access mode of reading
Dim fs As New FileStream(path & strSourceFile, FileMode.Open, FileAccess.Read)
Dim d As New StreamReader(fs)
Dim strChat As String = ""
While d.Peek() > -1
'peek method of StreamReader object tells how much more data is left in the file
strChat &= Server.HtmlEncode(d.ReadLine()).Replace(" ", " ") & "<br/>" & vbCrLf
End While
d.Close()
'displaying text from doc file in the Panel
Me.ltSource.Controls.Add(New LiteralControl(strChat))
Catch ex As Exception
Me.ltSource.Controls.Add(New LiteralControl("An Error has Occurred:<br/><br/> " & ex.Message))
Call EMailer.SendMail("", "", "Error in MySource.aspx", ex.Message)
End Try
End Sub
End Class
Copyright © 1984-2024 Dennis Day
All rights reserved