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

current folder name only 2

Status
Not open for further replies.

LikeThisName

Vendor
May 16, 2002
288
US

what is simplest / best way to get the current folder name (not the whole path)

for instance i have an asp include and I want it to be dynamic and set a variable to the name of the folder that it's in, regardless of the full path of the asp file.

can someone tell me how to do it in the least amount of line,

do i have to for instance get the whole path, count the slashes then and do a left function from that last slash.

any pointers appreciated

LikeThisName <- ? Sorry It's Taken =)
 
Take a look at the InStrRev function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

thankyou as always for pointing me in the right direction

phypath = cstr(server.MapPath(Request.ServerVariables("PATH_INFO")))
pos=InStrRev(phypath,"\")
phypath = left(phypath,pos-1)
pos=InStrRev(phypath,"\")+1
Response.write MID(phypath, pos)

can i do this in fewer lines?

LikeThisName <- ? Sorry It's Taken =)
 
Another way:
tmpArr = Split(cstr(server.MapPath(Request.ServerVariables("PATH_INFO"))), "\")
Response.write tmpArr(UBound(tmpArr) - 1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Or

response.write CreateObject("scripting.filesystemobject").getfolder(CurDir).Name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top