how to get the application directory? in vb, it is app.path, but i don't know in c#. thanks
Printable View
how to get the application directory? in vb, it is app.path, but i don't know in c#. thanks
Try these :
The first one will work for WinForms applications, the second for console-based applications.Code:public class Example
{
static public string ApplicationPath
{
get
{
return System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
}
}
static public string EntryAssemblyPath
{
get
{
return System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
}
}
}
Darwen.
Code:Application.StartupPath