string m_PathStr = Application.ExecutablePath;

解决方案 »

  1.   

    System.IO.Directory.GetCurrentDirectory()
      

  2.   

    System.IO.Directory.GetCurrentDirectory()
    这个方法,会随着你的当前系统路径的改变而改变.比如你打开一个openFileDialog那么,再次获得路径就不对了。
    string m_PathStr = Application.ExecutablePath;
    是能获得全部,包括exe文件名的一串东西比如c:\abc\abc.exe
    Application.StartupPath
    能够获得当前的运行路径,不包括执行文件名
    比如c:\abc\(又没有那个“\|”不记得了)
    自己分析你要那个吧
      

  3.   

    string exeRoad = System.Environment.CurrentDirectory.ToString();
      

  4.   

    同意
    Leo1949(笨蛋)所说的.
    使用
     Application.ExecutablePath;

    Application.StartupPath
      

  5.   

    Application.StartupPath!!!!!!!!
      

  6.   

    我是来鄙视一下的, 现在 .net 版怎么这么多人蹭分, 真是无耻!
    【木野狐】
      

  7.   

    to Leo1949(笨蛋):
        如果我用ConsoleApplication,怎么使用使用 Application.ExecutablePath;与Application.StartupPath?
        直接写是不行的,没有命名空间。
      

  8.   

    同意: Crystaltianshi(Crys) 并不是所有的人都是冲着分才回答问题的!
      

  9.   

    Application.StartupPath
    获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
      

  10.   

    Application.StartupPath,同意楼上的。如果使用string m_PathStr = Application.ExecutablePath;会取得执行文件的名称,这样如果去的所在目录的话还要处理。至于组件的路径我没有找到什么办法,我只能找到调用该组件的执行文件的路径,不能找到自己的路径
      

  11.   

    回答你:
    using System.Windows.Forms;
    当然,如果你是用控制台程序的话,那么还要加载那个System.Windows.Forms 的dll,就是引用里面拉