知道文件的路径,如何获得它所在文件夹的完全路径?

解决方案 »

  1.   

    path.substring(0,path.LastIndexOf(@"\"))
      

  2.   

    使用GetParent试试看,如:string str = System.IO.Directory.GetParent(Application.ExecutablePath).FullName;
    Console.WriteLine(str);
      

  3.   

    DirectoryInfo dd = new DirectoryInfo(FileName);
                   
    MessageBox.Show(dd.Parent.FullName);
      

  4.   

    字符串截取呀path.substring(0,path.LastIndexOf("\\"))