Determining the Execution Folder of an Assembly

  • Thread starter Thread starter Phil Jones
  • Start date Start date
P

Phil Jones

How would I go about finding the path of the folder that an assembly is
executing within? Specifically I'm concerned with how to do this from any
type of app other than a WinForms or IIS app (like a Console or a
WindowsService). I can do this from WinForms or IIS - it's with the other
types of apps that I'm stumped.

Rather than rely on each particular application shell, is there some way to
determine this just by looking at the assembly.

Thanks everyone.
===
Phil
(Auckland | Aotearoa)
 
Ohhhhhhhh!!! Yeah that works. Not sure why I didn't find that.

Cheers Sunny - appreciate the pointer.
===
Phil
 
Hi Phil,

I agree with Sunny's suggestion.
Did the code below work for you?
static void Main(string[] args)
{

Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().Location
.ToString());
}


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top