Get the current assembly path in ASP.NET


The get the current assembly’s path you could execute this code to get the current path:

Assembly.GetExecutingAssembly().Location

 

This code will return the directory where the assembly is curently located. For an ASP.NET application this will be “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files”.

To get the path of the assembly as it is installed (ex. c:\inetpub\wwwroot\<myapp>\bin) execute this code:

 

Path.GetDirectoryName(Assembly.GetAssembly(typeof(<myclass>)).CodeBase)

 

Advertisements
Tagged with:
Posted in .NET
One comment on “Get the current assembly path in ASP.NET
  1. Hi, I do think this is a great blog. I stumbledupon it 😉
    I may come back once again since I book-marked it. Money
    and freedom is the greatest way to change, may you be
    rich and continue to guide others.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: