Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP .net current physical location

Tags:

asp.net

xsl-fo

Hi I am developing an ASP.net web application. I need to find the current location (physical) of the web site (or the bin directory containing the assemblies).

I have tried using Directory.GetCurrentDirectory() and that returns me the ASP .net temporary directory.

I really don't like the idea of include an application setting for the absolute path in my config file (eww!)

Any help would be much appreciated! :)

Conclusion:

I should have given some context as to Why I would like the physical file path. Thanks guys for your prompt responses to the question :)

I am using XSL-FO for .net (the FO.net library) to generate a PDF. Embedding images in FO requires an absolute path to be given:

<fo:external-graphic src="C:\MyWebsite\images\image1.jpg" />

What I needed to do was set the current directory to the web site (or bin directory), which would allow the XSL FO renderer to know where to find the image.

like image 927
Russell Avatar asked Nov 16 '09 06:11

Russell


1 Answers

It depends on exactly what you want to do with the path, but the usual approach is Server.MapPath(). For example:

YourControl.src = Server.MapPath("~/images/image1.jpg");

That will return the physical path for the specified file.

like image 111
RickNZ Avatar answered Oct 21 '22 09:10

RickNZ