关于截去字符串的问题,谢谢,在线等!
文件路径为:C:\我的文档\我的文件夹\cyh.txt 
 我想截取字符串为:C:\我的文档\我的文件夹\ 
 请问如何实现   
 注意:文件路径不确定,可以是任何长度的文件路径   
 谢谢,在线等!
------解决方案--------------------string str = @ "C:\我的文档\我的文件夹\cyh.txt "; 
             int Index = str.LastIndexOf(@ "\ "); 
             string NewStr = str.Substring(0, Index+1); 
             MessageBox.Show(NewStr);
------解决方案--------------------string fileName = @ "C:\我的文档\我的文件夹\cyh.txt "; 
 string path = System.IO.Path.GetDirectoryName(fileName); 
 MessageBox.Show(path);
------解决方案--------------------用.net自带的FileInfo类   
 System.IO.FileInfo fileInfo = new System.IO.FileInfo(@ "C:\我的文档\我的文件夹\cyh.txt "); 
 string folder = fileInfo.DirectoryName;
------解决方案--------------------string str1 = @ "C:\我的文档\我的文件夹\cyh.txt ";  			 
 string str2=str1.Substring(0,str1.Length-7);
------解决方案--------------------string str = @ "C:\我的文档\我的文件夹\cyh.txt "; 
             int Index = str.LastIndexOf(@ "\ "); 
             string NewStr = str.Substring(0, Index+1); 
             MessageBox.Show(NewStr);