Forum Moderators: open

Message Too Old, No Replies

how to edit this

         

laura2k

1:38 pm on Dec 8, 2003 (gmt 0)



hello,

i have the following code in my script that basically creates ID.txt files in the same directory that my script is in,

fname = server.mappath(ID & ".txt")

i wanted to create another directory within my script folder called data and get the script to map to that instead.

i assumed maybe it will be something like this:

fname = server.mappath/data(ID & ".txt")

but that doesnt seem to work.

any help would be appreciated.

thanx in advanced

mattglet

3:30 pm on Dec 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you almost have it:

fname = server.mappath("data/" & ID & ".txt")

-Matt

edicius

3:31 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



Try:

Server.MapPath("/SomeDir/" & ID & ".txt")

laura2k

3:32 pm on Dec 8, 2003 (gmt 0)



thanx matt

laura2k

3:38 pm on Dec 8, 2003 (gmt 0)



i found a line in my script that has the following:

fname = server.mappath("data/" & ID + ".txt")

notice that this one has a + instead of a & after the ID, is this an error or is there a particular reason for that?

edicius

4:23 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



In the ASP.NET world - '&' is the VB.NET syntax, while '+' is the C# syntax.

In Classic ASP using VBScript I don't believe there is a difference. The better practice/recommended form in this case would be to use '&' since you're working with strings. The '+' side can cause confusion and possible errors down the road since it would add numeric data together rather than appending it to the end as you would have intended.

Example:
Response.Write(1 + "2") -- would return 3
Response.Write(1 & "2") -- would return 12