Question

How can I have a relative path in the web.config file. This value is not in the connection string so I cannot use |DataDirectory| (I think), so what can I do?

Was it helpful?

Solution

What is the relative path for?

Are you talking about a physical directory path or a url path?

Edit:

I needed to do something similar for one of my projects. I needed to locate a config file that was stored in a certain folder. While the web.config file itself does not provide anything special for this, you can take a path from the web.config file and convert it to an app-relative path.

Request.ApplicationPath gets you the base directory of the web application. YOu can append the relative path to this and give it to whatever needs it.

Also see this blog post by Rick Strahl for other interesting directories that may help you.

You could then append the relatvie path to

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top