Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the root path of a website from a dll?

I have a C# website. It references several compiled dlls. My dlls need to access folders on the website. How do I find the root path of the website from the dlls?

I've tried

System.Environment.CurrentDirectory - > "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE"

Assembly.GetExecutingAssembly().Location - > C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files......

I was going to use

System.Web.HttpContext.Current.Server.MapPath()

but System.Web.HttpContext.Current is null.

Thanks!

like image 448
Biff MaGriff Avatar asked Oct 25 '25 04:10

Biff MaGriff


1 Answers

You're looking for the HttpRuntime.AppDomainAppPath property, which can be used anywhere in an ASP.Net AppDomain.

like image 134
SLaks Avatar answered Oct 26 '25 16:10

SLaks