6 Replies - 40515 Views - Last Post: 16 August 2010 - 08:14 AM Rate Topic: -----

#1 fyrestorm   User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

finding root directory

Posted 09 October 2005 - 01:58 PM

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?
Is This A Good Question/Topic? 0
  • +

Replies To: finding root directory

#2 Amadeus   User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 253
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

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...
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...
Was This Post Helpful? 2

#3 fyrestorm   User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: finding root directory

Posted 09 October 2005 - 08:51 PM

thanks amadeus, i'll start there :)
Was This Post Helpful? 1

#4 Guest_Ajit*


Reputation:

Re: finding root directory

Posted 04 April 2010 - 06:44 AM

View Postfyrestorm, 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
Was This Post Helpful? 0

#5 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: finding root directory

Posted 05 April 2010 - 04:24 PM

@Ajit,

Use ResolveClientUrl, this will do what you're looking for. Like this

<img src='<%=ResolveClientUrl("~/images/myImage.jpg")%>' />



Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#6 Guest_PKG*


Reputation:

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!
Was This Post Helpful? 0

#7 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1