截取d:\myproject\bin最后一个\\之前的串

解决方案 »

  1.   

    string str=Application.StarupPath;
    int postion;
    postion=str.LastIndexof(str,"\\");
    string utree=str.Substring(str,1,postion);
      

  2.   

    DirectoryInfo mDir=new DirectoryInfo(Application.StartupPath);
    DirectoryInfo mDirF= mDir.Parent;
    MessageBox.Show(mDirF.FullName);
      

  3.   

    string dir=Application.StartupPath+"\\..";
    dir就是上一级了
    用过DOS的都应知道吧
      

  4.   

    string path=Application.StartupPath+"\\..";
    path就是上一级目录的字符串了,用CMIC(大象) 的方法也行,都可以。
      

  5.   

    string appPath=Application.StartupPath;
    System.IO.DirectoryInfo topDir=System.IO.Directory.GetParent(appPath);string topDirPath=topDir.FullName;//topDirPath即上层目录
      

  6.   

    Application.StartupPath + "\\.."