F:\WinForm\AutoUpde\AutoUpde\bin\Debug\AutoUpde.EXE
如何截取成F:\WinForm\AutoUpde\AutoUpde\bin\Debug\ 即是不要最後的AutoUpde.EXE?

解决方案 »

  1.   

    原來這麼簡單,自己搞定了
    string SavePathTemp = Application.ExecutablePath;
                string SavePath = Application.ExecutablePath.Substring(0, SavePathTemp.LastIndexOf("\\"));
      

  2.   

     string filePath = @"F:\WinForm\AutoUpde\AutoUpde\bin\Debug\AutoUpde.EXE";
               string name= System.IO.Path.GetFileName(filePath);
               string Path = filePath.Substring(0, filePath.LastIndexOf(name));
      

  3.   

    string filePath = @"F:\WinForm\AutoUpde\AutoUpde\bin\Debug\AutoUpde.EXE";
      string name= System.IO.Path.GetFileName(filePath);
      string Path = filePath.Substring(0, filePath.LastIndexOf(name));
      

  4.   

    string a = @"F:\WinForm\AutoUpde\AutoUpde\bin\Debug\AutoUpde.EXE";
                string b=a.Remove(a.LastIndexOf(@"\")+1);
                Console.WriteLine(b);
      

  5.   

    用什么正则!!这个简单的问题,用substring+lastIndexof就行了