You've got the key. You used MapPath to open the file. Why didn't you use it
to check for the file's existence?
If not ns.FileExists(server.mappath(zfil)) then
www.MessageMazes.com wrote:[color=blue]
> Greetings,
>
> I'm experimenting with an ASP page that reads data from a file name
> that is passed to it as a parameter, as in this page, which works,
> because the "good" file exists.
>
>
http://mazes.com/asp-maze/customized...&firstname=jwk
> (make "your name is an amazing asp.general programmer" mazes.
>
> But when I try this page, with the "bad" file which does not exist,
> I'm not succeeding:
>
http://mazes.com/asp-maze/customized...&firstname=jwk
>
> I've tried several solutions that I found by googling.
>
> When I tried:
> If (ns.FileExists(zfil)<>true) then ...
>
> but even when I give it a valid name, it returns "False"
>
> I've tried using
> On Error Resume Next
> set nq=ns.OpenTextFile(Server.MapPath(zfil),1,true)
> if Err.Number <> 0 Then ...
> On Error Goto 0
>
> I have found a workaround. Here is what finally worked:
>
> On Error Resume Next
> set nq=ns.OpenTextFile(Server.MapPath(zfil),1,true)
> if nq.AtEndOfStream=True Then
> zfil=custompath&"customdatadefault.asp"
> set nq=ns.OpenTextFile(Server.MapPath(zfil),1,true)
> end if
>
> But meanwhile, I'd love to hear how to check for the existence of a
> file.
>
> John[/color]
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.