"Rami Farhat" <Rami
Fa****@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.com...
Hi,
You can always find the directory path of the exe that started an
application using:
string myAppPath = Application.StartupPath;
Regards,
Rami Farhat
You can always use Application.
Wrong - only in a Windows Forms app can Application be used.
Even in a Windows Form app, I would still stay away from startup path, as
that does not actually indicate the location of the .exe file. For example,
if you had a shortcut to the EXE (say, on the start menu) you can go to it's
properties and change the startup path to some different directly.
The way I've normally gone about getting the location of the current exe is
to do something like this (if there is an easier way, let me know ;) )
string exeName = Assembly.GetExecutingAssembly().GetModules()[0].Name;
string path =
Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
path = path.Substring(0, path.Length - exeName.Length);
--
Adam Clauss