Groups | Blog | Home
all groups > c# > july 2007 >

c# : retrieve the application's path


Nicholas Paldino [.NET/C# MVP]
7/31/2007 1:11:52 PM
That's not guaranteed to give you the directory where the application
is, as the current directory can be changed through SetCurrentDirectory API.

A better solution would be to call the static GetEntryAssembly method on
the Assembly class, and then on that use the Location property or CodeBase
property (if shadow copying is a concern).


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

[quoted text, click to view]

Egghead
7/31/2007 2:33:53 PM
I use this "System.AppDomain.CurrentDomain.BaseDirectory." Other
application path methods give me the GAC path :)

--
cheers,
RL
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:uS%23EiV50HHA.4184@TK2MSFTNGP06.phx.gbl...
[quoted text, click to view]

Thanh-Nhan Le
7/31/2007 6:35:44 PM
Hi,
Is there any function to retrieve the application's path, path of the exe
file (as the property app.path of VB6).

thanks
Nhan

Morten Wennevik [C# MVP]
7/31/2007 6:45:56 PM
[quoted text, click to view]

Hi Nhan,

Try Environment.CurrentDirectory

--
Happy coding!
leon.friesema NO[at]SPAM frost-nospam-bits.nl
8/1/2007 12:00:00 AM
"Thanh-Nhan Le" <tnle_2003@yahoo.de> wrote on 7/31/2007 8:48:19 PM
[quoted text, click to view]
Application.ExecutablePath()
or
Application.StartupPath()

AddThis Social Bookmark Button