all groups > dotnet windows forms > july 2007 >
You're in the

dotnet windows forms

group:

Executable's path


Executable's path Patrick
7/26/2007 2:46:03 PM
dotnet windows forms:
With .net2, how do I get the path of where the .EXE is located for a WinForms
app? e.g. for "h:\myapps\testapp\test.exe" , "h:\myapps\testapp\" should
bee returned
Re: Executable's path Gregg Walker
7/26/2007 3:03:49 PM
c#

using System.IO;
using System.Reflection;

....

string pathDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);

or if you're really looking for the current directory...

string pathDir = System.Environment.CurrentDirectory;



AddThis Social Bookmark Button