retrieve the application's path

  • Thread starter Thread starter Thanh-Nhan Le
  • Start date Start date
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
 
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
 
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).
 
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).
 
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
 
Back
Top