C#正则表达式之从字符串文件路径中提取文件名和后缀名

 #region 09_从字符串文件路径中提取文件名和后缀名
            //string path = @"c:\windows\system32\drivers\etc\host.txt";
            Console.WriteLine("请输入完整文件路径:");
            string path = Console.ReadLine();
            Match match = Regex.Match(path, @".+\\(.+)");
            Console.WriteLine("文件名是:{0}",match.Groups[1].Value);
            Console.ReadKey();
            #endregion

猜你喜欢

转载自blog.csdn.net/xoofly/article/details/84339579
今日推荐