Getting exe's own filename?

  • Thread starter Thread starter jodleren
  • Start date Start date
J

jodleren

Hi all

I am very new to C#....

How do i get my own filename, like ParamStr(0) and Application.Exename
in Delphi?

/S
 
How do i get my own filename, like ParamStr(0) and Application.Exename
in Delphi?

There may be a better way, but try

string myExe = System.Reflection.Assembly.GetExecutingAssembly().Location;

It worked for a simple console app I tested.
 
Application.ExecutablePath (includes full path) or

Assembly.GetExecutingAssembly().GetName() (for just the name)
 
Hi all

I am very new to C#....

How do i get my own filename, like ParamStr(0) and Application.Exename
in Delphi?

/S

System.Windows.Forms.Application.ExecutablePath.

If System.Windows.Forms is referenced by a using statement, all you
need is Application.ExecutablePath.
 
jodleren said:
How do i get my own filename, like ParamStr(0) and Application.Exename
in Delphi?

Environment.GetCommandLineArgs()[0]
Assembly.GetExecutingAssembly().Location
Application.ExecutablePath

(ordered after my preference)

Arne
 
also you can use the Path class, within System.IO namespace

Path.GetFileNameWithoutExtension( Application.ExecutablePath );
Path.GetFileName( Application.ExecutablePath );

hope this helps,
Carlos

Arne Vajhøj said:
jodleren said:
How do i get my own filename, like ParamStr(0) and Application.Exename
in Delphi?

Environment.GetCommandLineArgs()[0]
Assembly.GetExecutingAssembly().Location
Application.ExecutablePath

(ordered after my preference)

Arne
 
Back
Top