LoserAndFailure
Programmer
I hope you guys can help me. I am doing an example out of the book "Beginning Active Server Pages 3.0", Chapter 10. This is an example about text streams. I copied this code WORD FOR WORD FROM THE BOOK and it DOESN'T WORK! The only way it will work is if I use THE AUTHOR'S code, which I downloaded from the Wrox website, which is IDENTICAL to mine! I am so upset! I want you guys to take a look at my code and compare it to the author's, and tell me if you can see any difference, and why mine isn't working. Theirs works BEAUTIFULLY and mine doesn't work AT ALL! I'm honestly beginning to believe it's because of who I am and has nothing to do with the code. Here are the codes below:
AUTHOR'S:
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strPathInfo, strPhysicalPath
strPathInfo = Request.QueryString("FileName")
strPhysicalPath = Server.MapPath(strPathInfo)
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
%>
<HTML>
<HEAD>
<TITLE><%= objFile.Name %> Source Code</TITLE>
</HEAD>
<BODY>
Source code for <%= objFile.Name %><HR><P>
<FONT FACE=Courier SIZE=2>
<%
Dim objFileTextStream
Set objFileTextStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
Dim strLine
Do While objFileTextStream.AtEndOfStream <> True
strLine = Server.HTMLEncode(objFileTextStream.ReadLine)
strLine = Replace (strLine, Chr(9), " ")
Response.Write strLine
Response.Write "<BR>" + vbCrLf
Loop
objFileTextStream.Close
%>
</FONT>
<BR>
<BR>
<HR>
<A HREF="<%= strPathInfo %>">Return to Displayed File</A>
</BODY>
</HTML>
MINE:
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strPathInfo, strPhysicalPath
strPathInfo = Request.QueryString("FileName")
strPhysicalPath = Server.MapPath(strPathInfo)
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
%>
<html>
<head>
<title><%= objFile.Name %> Source Code</title>
</head>
<body>
Source code for <%= objFile.Name %><hr><p>
<font face="Courier" size="2">
<%
Dim objFileTextStream
Set objFileTextStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
Dim strLine
Do While objFileTextStream.AtEndOfStream <> True
strLine = Sever.HTMLEncode(objFileTextStream.ReadLine)
strLine = Replace (strLine, Chr(9), " ")
Response.Write strLine
Response.Write "<br>" + vbCrLf
Loop
objFileTextStream.Close
%>
</font>
<br><br>
<hr>
<a href="<%= strPathInfo %>">Return to Displayed File</a>
</body>
</html>
I so hope you guys can help me, and I so hope this is a code problem and not an identity problem. Anyways your help will be greatly appreciated. Sorry for the length.
Sincerely,
LoserAndFailure
AUTHOR'S:
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strPathInfo, strPhysicalPath
strPathInfo = Request.QueryString("FileName")
strPhysicalPath = Server.MapPath(strPathInfo)
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
%>
<HTML>
<HEAD>
<TITLE><%= objFile.Name %> Source Code</TITLE>
</HEAD>
<BODY>
Source code for <%= objFile.Name %><HR><P>
<FONT FACE=Courier SIZE=2>
<%
Dim objFileTextStream
Set objFileTextStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
Dim strLine
Do While objFileTextStream.AtEndOfStream <> True
strLine = Server.HTMLEncode(objFileTextStream.ReadLine)
strLine = Replace (strLine, Chr(9), " ")
Response.Write strLine
Response.Write "<BR>" + vbCrLf
Loop
objFileTextStream.Close
%>
</FONT>
<BR>
<BR>
<HR>
<A HREF="<%= strPathInfo %>">Return to Displayed File</A>
</BODY>
</HTML>
MINE:
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim strPathInfo, strPhysicalPath
strPathInfo = Request.QueryString("FileName")
strPhysicalPath = Server.MapPath(strPathInfo)
Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
%>
<html>
<head>
<title><%= objFile.Name %> Source Code</title>
</head>
<body>
Source code for <%= objFile.Name %><hr><p>
<font face="Courier" size="2">
<%
Dim objFileTextStream
Set objFileTextStream = objFile.OpenAsTextStream(ForReading, TristateUseDefault)
Dim strLine
Do While objFileTextStream.AtEndOfStream <> True
strLine = Sever.HTMLEncode(objFileTextStream.ReadLine)
strLine = Replace (strLine, Chr(9), " ")
Response.Write strLine
Response.Write "<br>" + vbCrLf
Loop
objFileTextStream.Close
%>
</font>
<br><br>
<hr>
<a href="<%= strPathInfo %>">Return to Displayed File</a>
</body>
</html>
I so hope you guys can help me, and I so hope this is a code problem and not an identity problem. Anyways your help will be greatly appreciated. Sorry for the length.
Sincerely,
LoserAndFailure