日期:2014-05-17 浏览次数:20628 次
string source = @"F:\201206\绿色皮肤后台\SVN\WebUI\ImgUpload\images\title1.jpg";
Regex reg = new Regex(@"(?i)(?<=WebUI\\)[^""]+");
Match mm = reg.Match(source);
取 mm.Value
------解决方案--------------------
\SVN\WebUI这个路径变不变,不变 可以用楼上正则
------解决方案--------------------
DirectoryInfo dir = new DirectoryInfo(@"F:\201206\绿色皮肤后台\SVN\WebUI");
foreach (FileInfo dChild in dir.GetFiles("*.jpg"))
{
//如果用GetFiles("*.ini"),那么全部ini文件会被显示
Response.Write(@"\ImgUpload\images"+dChild.Name + "<br/>");
Response.Write(@"\ImgUpload\images" + dChild.FullName + "<br/>");//打印路径和文件名
}
------解决方案--------------------
正则或者substring都行
------解决方案--------------------
这个对你有帮助
使用这个分为两步
推荐方法 TraverseFolder =遍历文件夹下的图片
得到的是FileInfo[]
然后遍历fileInfo[] 这个是1.2版本的, 有个方法是去除 你指定字符返回后的值,是在1.3版本中加入的,目前正在更新中,如果需要请下载1.2版本获取联系方式!
祝你成功!
------解决方案--------------------
正则和字符串都可以
------解决方案--------------------
试一下
[string].Substring(s.LastIndexOf('\', 3));
------解决方案--------------------
string s = @"F:\201206\绿色皮肤后台\SVN\WebUI\ImgUpload\images\title1.jpg";
string r = Regex.Match(s, @"SVN\\WebUI(\\.+)").Groups[1].Value;
Response.Write(r);
------解决方案--------------------
string str=@"F:\201206\绿色皮肤后台\SVN\WebUI\ImgUpload\images\title1.jpg";
string a = str.Substring(str.IndexOf("\\ImgUpload"));
MessageBox.Show(a);