Advertisement

ASP File Stuff

Started by October 18, 2000 07:24 PM
2 comments, last by Agent1 24 years, 3 months ago
    
<%
SUB ReadDisplayFile(FileToRead)
   whichfile=server.mappath("/")
   Set fs = CreateObject("Scripting.FileSystemObject")
   Set thisfile = fs.OpenTextFile(whichfile, 1, False)
   tempSTR=thisfile.readall
   response.write tempSTR
   thisfile.Close
   set thisfile=nothing
   set fs=nothing
END SUB
%>
    
I prodded this little thing for a while (after finding it somewhere ). I am apparently not permitted to do the OpenTextFile. I''m just learning ASP, so I have no idea how else I might be able to do this. Any ideas?
-Agent1
Encrypted Transmission from Flagg, sent Tue Sep 19, 2000 4:45 PM: hehe... we're gonna have to change our number to unlisted...


Is the file identified by "whichfile" on the server or the client? The code you have listed is going to look for the file on the server (which may be your client too, if your developing on your web server) so it may not find it if it exists somewhere else.

Also, make sure that scripting is enabled on the client trying to access the asp page (IE\Options\Security\Custom).

You might try doing a response.write of "whichfile"s contents to make sure your getting what you expect.

Also, I know sometimes the samples posted aren''t actually the real thing, so i will ask if you have error handling in your code?

e.g.

set fs = CreateObject(...)

if not isObject( fs ) then
response.write "Failed to create FS Object!"
exit sub
end if




Advertisement


Is the file identified by "whichfile" on the server or the client? The code you have listed is going to look for the file on the server (which may be your client too, if your developing on your web server) so it may not find it if it exists somewhere else.

Also, make sure that scripting is enabled on the client trying to access the asp page (IE\Options\Security\Custom).

You might try doing a response.write of "whichfile"s contents to make sure your getting what you expect.

Also, I know sometimes the samples posted aren''t actually the real thing, so i will ask if you have error handling in your code?

e.g.

set fs = CreateObject(...)

if not isObject( fs ) then
response.write "Failed to create FS Object!"
exit sub
end if




It looks to me like you''re trying to open "/", which is not a file. It is a directory.
"No army has ever marched into battle thinking the Creator had sided with their enemy." - Terry Goodkind

This topic is closed to new replies.

Advertisement