i'm building a site in asp and I have includes in files in subdirectories that reference files in the root directory...
what I would like to do is find the root directory path (whether it be the current directory, ../, or ../../) in relation to the directory that I'm in that way I can have a variable in the script so that i don't have to hard code it in...
is there a way to do this?
finding root directory
Page 1 of 16 Replies - 40516 Views - Last Post: 16 August 2010 - 08:14 AM
Replies To: finding root directory
#2
Re: finding root directory
Posted 09 October 2005 - 07:24 PM
Try to out put the m path variable...see if that works...been a while, not sure it will...
If not, are you looking to have something that will find it dynamically so one function/variable set would work on different servers, or just one particular one...
Response.Write Server.MapPath("\")
If not, are you looking to have something that will find it dynamically so one function/variable set would work on different servers, or just one particular one...
#3
Re: finding root directory
Posted 09 October 2005 - 08:51 PM
thanks amadeus, i'll start there
#4 Guest_Ajit*
Re: finding root directory
Posted 04 April 2010 - 06:44 AM
fyrestorm, on 09 October 2005 - 07:51 PM, said:
thanks amadeus, i'll start there 
has this worked? i hv flash files and .js files in my root directory that i might use elsewhr especially my masterpage, which happens to be in the root. so i need a variable or some other way to get the tilde path of those files. any ideas? the problem is that the object tag is in HTML so can't use tilde path like ASP.net
#5
Re: finding root directory
Posted 05 April 2010 - 04:24 PM
@Ajit,
Use ResolveClientUrl, this will do what you're looking for. Like this
Hope that helps
Use ResolveClientUrl, this will do what you're looking for. Like this
<img src='<%=ResolveClientUrl("~/images/myImage.jpg")%>' />
Hope that helps
#6 Guest_PKG*
Re: finding root directory
Posted 16 August 2010 - 08:12 AM
I had a similar problem, and none of the above fitted great, as I was writing the path in a separate script file. I have shared my solution below (bit "hackish", i know):
I created a global function (on my masterpage) that returns the application path:
function getApplicationPath() {
return location.pathname.substr(0,location.pathname.indexOf('/',location.pathname.indexOf('BitOfApplicationName',0)));
}
The 'BitOfApplicationName' should be replaced with a bit of your application name that always will appear in both test and published versions.
This can then be used anywhere with javascript paths in such a manner:
getApplicationPath() + '/images/calendar.png'
Hope that helps!
I created a global function (on my masterpage) that returns the application path:
function getApplicationPath() {
return location.pathname.substr(0,location.pathname.indexOf('/',location.pathname.indexOf('BitOfApplicationName',0)));
}
The 'BitOfApplicationName' should be replaced with a bit of your application name that always will appear in both test and published versions.
This can then be used anywhere with javascript paths in such a manner:
getApplicationPath() + '/images/calendar.png'
Hope that helps!
#7
Re: finding root directory
Posted 16 August 2010 - 08:14 AM
PKG, I appreciate your willingness to help. However, as this thread is from 2005, I doubt the OP is still checking back. Please avoid necroposting in the future.
Page 1 of 1

New Topic/Question
Reply



MultiQuote





|