你型我塑博客

snryang

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  24 随笔 :: 8 文章 :: 29 评论 :: 0 引用
using System.Net;

Regex   re   
=   new   Regex(@"src\s*=\s*(?:([""'])(?<src>[^""']+)\1|(?<src>[^\s>]+))",   RegexOptions.IgnoreCase   |   RegexOptions.Singleline);   
            MatchCollection   mc   
=   re.Matches(this.Editor1.XHTML.ToString());   
            
foreach   (Match   m   in   mc)   
            
{   
                
string url=m.Groups["src"].Value;
                
string filepath=url;
                
if(url.Substring(0,7).ToLower()=="http://")
                
{
                    
string KuoZhangMing="."+url.Substring(url.LastIndexOf(".")+1);
                    
string path = HttpContext.Current.Server.MapPath(@"/MLXZ/Uploads/Download/");
                    
string filename=DateTime.Now.ToString("yyyyMMddHHmmss")+KuoZhangMing;
                    path
=path+filename;
                    filepath
=@"/MLXZ/Uploads/Download/"+filename;
                    WebClient myWebClient 
= new WebClient();
                    myWebClient.DownloadFile(url,path);
                    
this.Editor1.Text=this.Editor1.XHTML.ToString().Replace(url,filepath);
                }

                Pic.Items.Add(
new   ListItem(filepath,filepath)); 
            }
上面代码实现了提取编辑器中的图片地址,如果图片地址为网上的,则会自动保存到本地.其它是的editor1为一个编辑器CuteEditor
posted on 2007-03-14 14:31 snryang 阅读(339) 评论(3)  编辑 收藏

评论

大大大大大大大
  回复  引用    

using System.Net;

Regex re = new Regex(@"src\s*=\s*(?:([""'])(?<src>[^""']+)\1|(?<src>[^\s>]+))", RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollection mc = re.Matches(this.Editor1.XHTML.ToString());
foreach (Match m in mc)
{
string url=m.Groups["src"].Value;
string filepath=url;
if(url.Substring(0,7).ToLower()=="http://")
{
string KuoZhangMing="."+url.Substring(url.LastIndexOf(".")+1);
string path = HttpContext.Current.Server.MapPath(@"/MLXZ/Uploads/Download/");
string filename=DateTime.Now.ToString("yyyyMMddHHmmss")+KuoZhangMing;
path=path+filename;
filepath=@"/MLXZ/Uploads/Download/"+filename;
WebClient myWebClient = new WebClient();
myWebClient.DownloadFile(url,path);
this.Editor1.Text=this.Editor1.XHTML.ToString().Replace(url,filepath);
}
Pic.Items.Add(new ListItem(filepath,filepath));
using System.Net;

Regex re = new Regex(@"src\s*=\s*(?:([""'])(?<src>[^""']+)\1|(?<src>[^\s>]+))", RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollection mc = re.Matches(this.Editor1.XHTML.ToString());
foreach (Match m in mc)
{
string url=m.Groups["src"].Value;
string filepath=url;
if(url.Substring(0,7).ToLower()=="http://")
{
string KuoZhangMing="."+url.Substring(url.LastIndexOf(".")+1);
string path = HttpContext.Current.Server.MapPath(@"/MLXZ/Uploads/Download/");
string filename=DateTime.Now.ToString("yyyyMMddHHmmss")+KuoZhangMing;
path=path+filename;
filepath=@"/MLXZ/Uploads/Download/"+filename;
WebClient myWebClient = new WebClient();
myWebClient.DownloadFile(url,path);
this.Editor1.Text=this.Editor1.XHTML.ToString().Replace(url,filepath);
}
Pic.Items.Add(new ListItem(filepath,filepath));

  回复  引用    

#3楼  2008-05-16 18:03 大幅度 [未注册用户]
为什么 我单独 使用 能用 项入程序中就 去不到图片

哥哥 你 在线么
  回复  引用    


标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接: