Application.StartupPath
or
System.Environment.CurrentDirectory得到的是应用程序路径。Assembly.GetExecutingAssembly().Location;

解决方案 »

  1.   

    樓上的
    這只不過得到執行EXE文件的路經
    我是想得到當前如經:
    例如:一有個窗體FrmMain中有一個按鈕ButtonOK
    當單擊ButtonOK得到FrmMain的路經?
      

  2.   

    你說的這只不過得到執行EXE文件的路經
      

  3.   

    拷贝到你的ButtonOK的Click事件中:
    MessageBox.Show(Application.StartupPath);如果还不行,贴上你的code来。
      

  4.   


    private void FrmRep101_Load(object sender, System.EventArgs e)
    {

    MessageBox.Show(Application.StartupPath);
    }
    它顯示的是“F:\doc\MyApp\bin\Degbug”
    我創的工程是放在F:\doc裡面
      

  5.   

    用这个exe是没有办法来得到你工程所在的目录的。因为F:\doc\MyApp\bin\Degbug完全是在VS.Net的中设置的。如果你要用这个目录下的东西,一个建议是把所要用的东西拷贝到exe所在的目录。
    如果你是使用的却生配置,也可以这样,但是不敢一旦这个exe拷贝的其他的地方,就有可能有问题。
    DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());MessageBox.Show(dir.Parent.Parent.FullName);
      

  6.   

    如果我想得到這個呢
    F:\doc\MyApp