retrieve the application's path

T

Thanh-Nhan Le

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
 
M

Morten Wennevik [C# MVP]

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

Hi Nhan,

Try Environment.CurrentDirectory
 
N

Nicholas Paldino [.NET/C# MVP]

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).
 
E

Egghead

I use this "System.AppDomain.CurrentDomain.BaseDirectory." Other
application path methods give me the GAC path :)

--
cheers,
RL
Nicholas Paldino said:
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).
 
L

leon.friesema

Thanh-Nhan Le said:
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
Application.ExecutablePath()
or
Application.StartupPath()

gr.Leon
 

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