9

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

Nils Magne Lunde
  • 1,794
  • 1
  • 13
  • 21
sreenu
  • 443
  • 5
  • 9
  • 16

5 Answers5

15

This will return the complete path to your Application

System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
FosterZ
  • 3,863
  • 6
  • 38
  • 62
5

You can do it like this as well

          System.AppDomain.CurrentDomain.BaseDirectory
Furqan Hameedi
  • 4,372
  • 3
  • 27
  • 34
2

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

Felice Pollano
  • 32,832
  • 9
  • 75
  • 115
1

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

using System.Windows.Forms;
x2.
  • 9,554
  • 6
  • 41
  • 62
0

Generally, Application.StartupPath() will give the path of the application. And also r u missing this namespace. System.Windows.Forms