Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the application physical path in windows forms application

Tags:

c#

winforms

how to get the application path in windows forms , i used the bellow code but it is saying like "method not found"

Application.ExecutablePath;
Application.StartupPath;

please suggest me am i missing any namespace ?

thanks in advance

like image 933
sreenu Avatar asked Apr 26 '11 10:04

sreenu


People also ask

What is application path?

A program's App Paths key typically contains a value named Path, which should contain a semicolon-delimited list of directories where the program's . dll files could be located. Windows uses this key to find your application and its . dll files if their locations are not already in the system's path.

How do I deploy Windows Forms application?

Right click on Project menu and click on "Project name Properties". Click the sign in option and select the checkbox (Sign the Click Once manifests). Go to Security >> select Check Box (Enable Click Once Security Settings). Go to Publish >> select Publishing folder location path and Save.


4 Answers

This will return the complete path to your Application

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
like image 184
FosterZ Avatar answered Oct 03 '22 08:10

FosterZ


You can do it like this as well

          System.AppDomain.CurrentDomain.BaseDirectory
like image 35
Furqan Hameedi Avatar answered Oct 03 '22 07:10

Furqan Hameedi


System.Windows.Forms.Application.StartupPath must return the path of the running executable.

like image 43
Felice Pollano Avatar answered Oct 03 '22 09:10

Felice Pollano


Add reference System.Windows.Forms and add in using section

using System.Windows.Forms;
like image 39
x2. Avatar answered Oct 03 '22 07:10

x2.