关于截去字符串的问题,谢谢,在线等! 文件路径为:C:\我的文档\我的文件夹\cyh.txt我想截取字符串为:C:\我的文档\我的文件夹\请问如何实现注意:文件路径不确定,可以是任何长度的文件路径谢谢,在线等! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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; 何必要自己分割呢,最简单的就是最好的-----------离开了.Net,你怎么办? 本页页面的顶部BANNER下面有个“管理”,点这个链接。 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); 求解反射问题。。大虾请帮忙出点点子。。万分感谢。。(100分) 请教:关于字段初始化的问题 在datagrid里怎么获取已知行列中的值(window form) 关于ADO.net将一个表插入数据库的问题 菜鸟问题 C#能声明可选参数否 每次调试都全部重新生成一次解决方案下的所有项目,不管修改没修改.我的解决方案太大,每次都重新生成太麻烦了.有没有哪位大神遇到过这种情况? 寻找技术合伙人 C# word 多行之间的编号样式,项目符号怎么得到 在C#下如何使用ActiveX控件 vc#下如何使用dll,谢谢 各位高手看看int 值的问题 线程安全问题。
int Index = str.LastIndexOf(@"\");
string NewStr = str.Substring(0, Index+1);
MessageBox.Show(NewStr);
string path = System.IO.Path.GetDirectoryName(fileName);
MessageBox.Show(path);
string folder = fileInfo.DirectoryName;
何必要自己分割呢,最简单的就是最好的
-----------
离开了.Net,你怎么办?
string str2=str1.Substring(0,str1.Length-7);
int Index = str.LastIndexOf(@"\");
string NewStr = str.Substring(0, Index+1);
MessageBox.Show(NewStr);