Click to See Complete Forum and Search --> : Problems with Server.MapPath


nyfiken
04-06-2005, 06:47 AM
Hello! :confused:

The code below creates a new text file each month and writes information from all visitor from my homepage. But I want the file to be written in another folder and I wonder how to do? Let's say that the folder is called visitor?

Regards nyfiken :)

<html>
<body bgcolor="#ffffff">
<%
ar = Right(Year(Date),2)
manadnummer = Month(Date)
manadnamn = Monthname(Month(Date))
filnamn = manadnamn + ar

Set TxtObject = Server.CreateObject("Scripting.FileSystemObject")

plats = Server.MapPath(filnamn+".txt")
Set TxtFile = TxtObject.OpenTextFile(plats,8,true)
TxtFile.WriteLine WeekdayName(Weekday(Date))
TxtFile.WriteLine Day(Date)
TxtFile.WriteLine Monthname(Month(Date))
TxtFile.WriteLine Time
TxtFile.WriteLine Request.ServerVariables("remote_addr")
TxtFile.WriteLine Request.ServerVariables("http_user_agent")
TxtFile.WriteLine "end"
TxtFile.Close
%>
</body>
</html>

buntine
04-06-2005, 06:53 AM
Try:

plats = Server.MapPath("visitor\" & filnamn+".txt")

You may have to explicitely create the file:

TxtObject.CreateTextFile(plats, true)

Regards.