C#字符串拆分 从“c:/Inetpub/wwwroot/sites/blabla/info.html” 中却出 info该怎么写啊!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string str = "c:/Inetpub/wwwroot/sites/blabla/info.html"; str = Regex.Match(str, @"\w+(?=\.)").Value; Console.WriteLine(str);结贴吧 又是正则,以‘/’开始以.html结束~ string str = "c:/Inetpub/wwwroot/sites/blabla/info.html"; str = str.Substring(str.LastIndexOf("1") + 1, 4); string s ="c:/Inetpub/wwwroot/sites/blabla/info.html"; string[] strs =s.Split('/'); Console.WriteLine(strs[strs.Length - 1].Replace(".html", "")); string fileName = @"C:\mydir\myfile.ext";string path = @"C:\mydir\";string result;result = Path.GetFileNameWithoutExtension(fileName);Console.WriteLine("GetFileNameWithoutExtension('{0}') returns '{1}'", fileName, result);result = Path.GetFileName(path);Console.WriteLine("GetFileName('{0}') returns '{1}'", path, result);// This code produces output similar to the following://// GetFileNameWithoutExtension('C:\mydir\myfile.ext') returns 'myfile'// GetFileName('C:\mydir\') returns ''Path.GetFileNameWithoutExtension 方法http://msdn.microsoft.com/zh-cn/library/system.io.path.getfilenamewithoutextension(v=vs.80).aspx 严格地说,你必须用这个方法,而不是什么字符串拆分,因为.NET被设计为一种跨操作系统的Runtime,而不同操作系统的路径分割符是不同的。 大家帮忙看下啊。。在等。。。。 C# (winfrom)怎么写弹出一窗体 返回true or false ListView里的右键菜单 c# 的 变量 菜鸟问题 [新手问一下关于Remoting的弱弱的问题] 如何屏蔽WebBrowser的右键 c#如何重绘mdi窗体 好菜的问题,如何获取当前时间? 我怎么在sql语句中,定义两列为主键啊!帮帮忙啊! 请大家帮忙看看 各位大神,如何把activated事件按出来 datagridview 快速输入,复制的问题。
str = Regex.Match(str, @"\w+(?=\.)").Value;
Console.WriteLine(str);
结贴吧
str = str.Substring(str.LastIndexOf("1") + 1, 4);
string[] strs =s.Split('/'); Console.WriteLine(strs[strs.Length - 1].Replace(".html", ""));
string path = @"C:\mydir\";
string result;result = Path.GetFileNameWithoutExtension(fileName);
Console.WriteLine("GetFileNameWithoutExtension('{0}') returns '{1}'",
fileName, result);result = Path.GetFileName(path);
Console.WriteLine("GetFileName('{0}') returns '{1}'",
path, result);// This code produces output similar to the following:
//
// GetFileNameWithoutExtension('C:\mydir\myfile.ext') returns 'myfile'
// GetFileName('C:\mydir\') returns ''
Path.GetFileNameWithoutExtension 方法http://msdn.microsoft.com/zh-cn/library/system.io.path.getfilenamewithoutextension(v=vs.80).aspx
严格地说,你必须用这个方法,而不是什么字符串拆分,因为.NET被设计为一种跨操作系统的Runtime,而不同操作系统的路径分割符是不同的。