How to get Application Path?

  • Thread starter Thread starter Frank Rizzo
  • Start date Start date
F

Frank Rizzo

How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks
 
Try Win32 API function GetCommandLine(). It should return the command line
with full application path. Sorry if it is not true, I don't have personal
experience with that.

Eliyahu
 
Environment.CurrentDirectory

??

run cmd.exe
cd c:\
run prog for example
c:\winnt\prog.exe
if try write Environment.CurrentDirectory

it return "c:\"
 
Sorry I got busy with my office work so I didn't saw this

................., (You yourself fill the blank with the suitable word)

Yes I read to the end of the post and I understood it and bellow is how I ask you to do, though your small brain cannot get it.

Application.StarupPath doesn't use Windows Forms nore it return the path as file://c/winnt/.../filename.exe where you cannot use for file loading etc..
It will return the path in a way, which you can create a FileInfo object and use to get almost all the details you need such as directory, directoryName, File Name, Full Path etc,,,,,,,,,,,,,,,,

Other than that it will give the actual path even if you load the assembly using a Shoutcut icon.

Nirosh.
 
Back
Top