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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Full url for sPath?

Status
Not open for further replies.

gwillr

IS-IT--Management
Nov 4, 2003
267
CA
I have a few pages in different areas that must reference a count in the same text file via asp.
Code:
<%
Dim sPath, filesys, count, getValue, update, twohrs 
sPath = Request.ServerVariables("Path_Translated") 
sPath = Left(sPath,InStrRev(sPath,"\")) & "counter8.txt" 
Set filesys = CreateObject("Scripting.FileSystemObject") 
Set getValue = filesys.OpenTextFile(sPath,1,0) 
count = getValue.ReadLine 
If Request.Cookies("blog")("recentvisitor") <> "yes" Then
 count = Int(count) + 1 
End If 
getValue.Close
%>
							
<%
If Request.Cookies("blog")("recentvisitor") <> "yes" Then 
Set update = filesys.CreateTextFile(sPath) 
update.WriteLine(count) 
update.Close 
Response.Cookies("blog")("recentvisitor") = "yes" 
twohrs = DateAdd("h", 1, Now) 
Response.Cookies("blog").Expires = twohrs 
End If 
%> 
							
<%
count = FormatNumber(count, 0, 0, -1, -1)            
response.write "<font class='statred'>["& count &"]</font>"
%>

Can i specify the file 'count8' somehow so that each page references the file from no matter what folder the page is in? I have tried using the full url, but it dindt work as i had suspecte.

Gary

 
Gary,

Set a seesion variable.
Session("MyInfo")="count8"
then write it to any page in the session.

Response.write Session("MyInfo")



I hope I understood you question correctly.

Dan
 
your use of PATH_TRANSLATED is the problem. This will return a physical path relative to the script not relative to the root.
Code:
sPath = server.MapPath("\folder\filename")

should work.

or
Code:
sPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "folder\filename"


Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top