PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Executable's path

Reply

Executable's path

 
Thread Tools Rate Thread
Old 26-07-2007, 10:46 PM   #1
=?Utf-8?B?UGF0cmljaw==?=
Guest
 
Posts: n/a
Default Executable's path


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

  Reply With Quote
Old 26-07-2007, 11:03 PM   #2
Gregg Walker
Guest
 
Posts: n/a
Default Re: Executable's path

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;




  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off