- The simple way through windows forms:
using System.Windows.Forms;
String sAppPath1 = Application.StartupPath; - From the binary over reflection:
String sAppPath2 = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ); - Using the file informations:
FileInfo executableFileInfo = new FileInfo (Application.ExecutablePath);
String sAppPath3 = executableFileInfo.DirectoryName; - When my program is started from another:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
martedì 9 giugno 2009
Application Path
Sometime I need to retrieve the application path, here I add the four methods I use frequently.
Iscriviti a:
Commenti sul post (Atom)
1 commento:
Posta un commento