absolute path to url

H

Harrie Verveer

is there a way to convert an absolute path
(C:\inetpub\wwwroot\project\folder\another_folder\file.jpg) to an url?

I used this code:
---
string sk = Server.MapPath(".").ToLower();
url_to_use = filename.ToLower().Replace(sk,".").Replace("\\","/");
---

My problem now is that the file resides in another project folder on the
server (please don't ask why :p). The solution whould be to do something
like:

---
string sk = <path_of_wwwroot>
url_to_use = filename.ToLower().Replace(sk,"/").Replace("\\","/");
---

But I can't find a way to find the location of wwwroot - except for
MapPath(".."), which is not allowed :)

Anyone knows a solution?
 
G

Guest

if MapPath not allowed and the location is bound to future changes, one
method would be to keep a config key for this location..

you may have thought about this workaround already, in case u have not

<add key="another_folder" value="http://yoursite/yourroot/another_folder/"
/>


url_to_use = ConfigurationSettings.AppSettings["another_folder"] +
filename;

Sreejith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top