Getting path of executing assembly
-
I am trying to get the path of the executing .exe, but so far with no luck. I have tried Assembly.GetExecutingAssembly().CodeBase but this just returns the path to the .dll does anyone know how to get the path of the .exe? thanks
Application.ExecutablePath
ist what you're looking for.Regards, mav -- Black holes are the places where God divided by 0...
-
I am trying to get the path of the executing .exe, but so far with no luck. I have tried Assembly.GetExecutingAssembly().CodeBase but this just returns the path to the .dll does anyone know how to get the path of the .exe? thanks
string path1 = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
string path2 = System.Environment.CurrentDirectory;
using System.Windows.Forms;
string path3 = Application.ExecutablePath;The value for path1 on my system is "file:\\K:\\VS2008\\ConsoleTester\\ConsoleTester\\bin\\Debug" The value for path2 on my system is "K:\\VS2008\\ConsoleTester\\ConsoleTester\\bin\\Debug" The value for path3 on my system is "K:\\VS2008\\ConsoleTester\\ConsoleTester\\bin\\Debug\\ConsoleTester.exe"
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Application.ExecutablePath
ist what you're looking for.Regards, mav -- Black holes are the places where God divided by 0...
Bearing in mind this only applies to a Windows Forms application.
Semicolons: The number one seller of ostomy bags world wide. - dan neely
-
I am trying to get the path of the executing .exe, but so far with no luck. I have tried Assembly.GetExecutingAssembly().CodeBase but this just returns the path to the .dll does anyone know how to get the path of the .exe? thanks
Assembly.GetEntryAssembly().CodeBase
will give you the full .exe URI. To get the full file system path, use:
Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), Path.GetFileName(Assembly.GetEntryAssembly().CodeBase));
Semicolons: The number one seller of ostomy bags world wide. - dan neely
-
Assembly.GetEntryAssembly().CodeBase
will give you the full .exe URI. To get the full file system path, use:
Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), Path.GetFileName(Assembly.GetEntryAssembly().CodeBase));
Semicolons: The number one seller of ostomy bags world wide. - dan neely