any suggestions?
Code follows:
Hi,
<%@dotnet.itags.org. Import Namespace="System.IO" %>
<Script language="VBScript" Runat="Server"
Sub Page_Load
Dim objStreamReader As StreamReader
Dim strInput As StringIf File.Exists(MapPath("readtest.txt") ) Then
objStreamReader = File.OpenText(MapPath("readtest.txt") )
strInput = objStreamReader.ReadLine()
While strInput <> Nothing
lblContents.Text &= "<li>" & strInput
strInput = objStreamReader.ReadLine()
End While
objStreamReader.Close
Else
'This line writes to the browser even though the file exists.
lblContents.Text = "readtest.txt does not exist!"
End IfEnd Sub
</Script
<html>
<head><title>OpenText.asp</title></head>
<body bgcolor="#FFFFFF"
<h3>Contents of readTest.txt</h3>
<asp:Label
ID="lblContents"
Runat="Server" /
<br>
'The path of the file is written to the browser.
<%
Response.Write(Server.MapPath("readtest.txt"))
%>
</body>
</html>
can you also provide the exact error that ASP.NET throws at you?
Grz, Kris.
Note that your Response.Write and File.Exists lines are calling 2 different functions.
I am not sure what the differences are, but I'd start by outputting the results of the same function.
System.Web.Server.MapPath()
System.Web.UI.Page.MapPath()
0 comments:
Post a Comment