Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP File Path 1

Status
Not open for further replies.

Geee

Programmer
Apr 23, 2001
253
GB
I know I have read this in this forum before, but however much I search I can't seem to find it!!!

What I want to do is make reference to the physical path that the asp file being call resides in. Does that make sense?

Basically I want to generate a log file of failed logins to my site. This is not a problem using the FileSystem object. I can create or open a current log, write the info to it and then close it. But I want the logs to sit in the logs/ directory of my website. As I have no way of knowing the directory structure of my server, I need to find the path that the asp file being called is sitting in, and add logs/ to it. Any ideas???

Gary
 
Use
Request.ServerVariables("Script_Name")

that will return the virtual path to the calling script.


BTW -
If you do a server.MapPath("filename.asp"), that will return the absolute path to the file. So, why don't you create some new file, ex: abcdef.ghi in your logs directory, then Server.MapPath that. hack off the abcdef.ghi, then you've got the absolute path to your logs directory.

Hope this helps -
leo
 
Thanks that helps a lot however ... =)

Do you know how to move to the end of a text file using the filesystemobject?

I currently have...

<%
set FSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set MyFile = FSO.OpenTextFile (Filename,8)
MyFile.WriteLine LogLine
MyFile.Close
Set FS0 = Nothing
%>

But I want to know the command to put in before the WriteLine to move to the end of the file.

Any Ideas????
 
set data2=objfso.opentextfile(datafile2, 8)
data2.writeline(&quot;num&quot;)
data2.close

works perfict which means since its the same as your code yours works perfict. doing opentxtfile(file, 8) tells it to open it as append. meaning its opened and advanced to the bottom of the file Karl Pietri
 
Yes I know. Sorry to waste your time. I hadn't tested properly. Thanks anyway.

Gary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top