Results 1 to 2 of 2

Thread: Server.mappath

  1. #1
    Join Date
    Dec 1969

    Default Server.mappath

    Hi ,<BR> I want to open a text file using System.filescripting object<BR>The problem is i want to take the physical path of the text file using server.mappath method.<BR> when i write, response.write server.mappath("filename")<BR>it shows me the output.But when i want to open it as<BR>filename=rs.fields("filename")<BR> set MyTextFile2=MyFileObject.OpenTextFile(server.mappa th(filename),1).<BR>I even tried taking server.mappath(filename) in a variable.But it didn&#039t work.<BR><BR>It says the file does not exists but actually it does exists.<BR> The code works fine without server.mappath.<BR>can anyone help me?<BR><BR>thanx in advance.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Server.mappath

    I use a text file to track some information when a switch is set. When tracking is turned on I use Path_Translated to get the current directory. Because my text file is not in the same place as the ASP page running, I strip off what I need and add the path of where my text file is. I store the file path in a session variable, so I do not have to continually get the file path while tracking timings.<BR> <BR> strPath = Request.ServerVariables("PATH_TRANSLATED")<BR> strPath = Left(strPath, (InStr(strPath, "Scripts\")+ 7))<BR> strPath = strPath & "loggingLog.txt"<BR> Set Session("LogFile") = strPath<BR><BR> Set objFSO = CreateObject("Scripting.FileSystemObject")<BR> Set oLogFile = objFSO.CreateTextFile(strPath,True)<BR> strLine = "Some information I want to write to the text file when I turn tracking on"<BR> oLogFile.Writeline(strLine)<BR><BR> oLogFile.Close<BR> set objFSO = nothing<BR> set oLogFile = nothing<BR><BR>Later when I want to add a new line to the text file:<BR> &#039 open the text file and add our message<BR> Set objFSO = CreateObject("Scripting.FileSystemObject")<BR> strPath = Session("LogFile")<BR> Set oLogFile = objFSO.OpenTextFile(strPath,8)<BR><BR> strLine = “Some information I want to add to the file”<BR> oLogFile.Writeline(strLine)<BR><BR> oLogFile.Close<BR> set objFSO = nothing<BR> set oLogFile = nothing<BR>

Posting Permissions

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