Path of the running application

  • Thread starter Thread starter Le, Thanh-Nhan
  • Start date Start date
L

Le, Thanh-Nhan

Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan
 
Nhan,

You can get the entry point for the application by calling the static
GetEntryPoint method on the Assembly type and getting the entry point of the
assembly that was used to launch the CLR.

Once you have that, you can use the Location property on the assembly
returned to find out where it is being executed from.

Hope this helps.
 
Use Application.StartupPath.

Hi,
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

Thanks
Nhan
 
How can I retrieve the path of the current application (written in C#)?
In VB6 I can do it with property path of app object (app.path).

I assume that you want the path where the executable is located that is now
running?

Something like this:

using System.Reflection;

Assembly myAssembly = Assembly.GetExecutingAssembly();
string ExecutableFileAndPath=myAssembly.CodeBase;
string ThePath=Path.GetFullPath(ExecutableFileAndPath);
 
Thanks

Olaf Baeyens said:
I assume that you want the path where the executable is located that is now
running?

Something like this:

using System.Reflection;

Assembly myAssembly = Assembly.GetExecutingAssembly();
string ExecutableFileAndPath=myAssembly.CodeBase;
string ThePath=Path.GetFullPath(ExecutableFileAndPath);
 
Back
Top