server.MapPath error

Results 1 to 2 of 2

Thread: server.MapPath error

  1. #1
    meeta Guest

    Default server.MapPath error

    I can&#039;t seem to figure out how to specify url in server.MapPath.<BR>I want to read content of files. These Filenames would be made out of string, part of which is stored in array. It does printout right, when i checked. but Its showing file not found.<BR>Files are in the same folder. Also If files are under one level below from where I want to read, how can you spcify exact url. Below is my code to read file. (also please tell me how to specify folder if i want to write file one folder above or read from a file one level below)<BR><BR>temp = pid & t & indid &#039; pid, t values are coming from previous page (get method), indid) is coming off database<BR>FileName = temp &".txt"<BR>fname = server.MapPath("./admin")& FileName &#039;spcify folder location file is one level down from file trying to read<BR>dim fs<BR>set fs=Server.CreateObject("Scripting.FileSystemObject ")<BR>dim fso<BR>if fs.FileExists("fname") then<BR> Set fso=fs.OpenTextFile(fname,1,False)<BR> Response.Write "&#060;font face=arial size=1&#062;" & fso.ReadAll & "&#060;/font&#062;"<BR> fso.Close<BR> Set fso = Nothing<BR>else <BR> response.write ""<BR> Response.Write "file does not exist " & FileName <BR>end If<BR>set fs=nothing<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Bill's mantra: DEBUG DEBUG DEBUG

    Did you *ever*, after executing this line:<BR><BR>&nbsp; &nbsp; &nbsp; fname = server.MapPath("./admin")& FileName <BR><BR>*then* do <BR><BR>&nbsp; &nbsp; &nbsp; Response.Write "&#060;HR&#062;fname is " & fname & "&#060;HR&#062;"<BR><BR>???<BR><BR>I betcha if you would do that you&#039;d immediately see your bug.<BR><BR>If not, then tell us what that *does* display and we&#039;ll see if we can help. But I&#039;ll bet you will see it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts