Determining the Execution Folder of an Assembly

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)
 
P

Phil Jones

Ohhhhhhhh!!! Yeah that works. Not sure why I didn't find that.

Cheers Sunny - appreciate the pointer.
===
Phil
 
P

Peter Huang

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top