3.1.6 命名空间引用
using System.IO;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using MSXML2;
3.2 核心代码
3.2.1 远程图片上传模块
/// <summary>
/// 自动远程上传图片模块
/// </summary>
private void UploadRemote()
{
ArrayList InputBoxVlaue = new ArrayList();
//获得远程图片Url地址列表
InputBoxVlaue = RegExpExecuteRemoteImg(FCK_Content.Value);
//循环读取图片数据并上传
for (int i = 0; i <= InputBoxVlaue.Count - 1; i++)
{
//读取图片数据,上传图片,返回上传图片路径。
string Newurl = ReadWriteRemoteData(InputBoxVlaue[i].ToString());
if (Newurl != "")
{
string pattern = InputBoxVlaue[i].ToString();
//替换远程图片路径为新上传的图片路径
Regex reg = new Regex(pattern);
FCK_Content.Value = reg.Replace(FCK_Content.Value, Newurl);
}
}
}
3.2.2 图片Url地址过滤模块
/// <summary>
/// 分析字符串,找出远程图片路径
/// </summary>
/// <param name="Str">源字符串</param>
/// <returns>返回图片路径数组</returns>
public ArrayList RegExpExecuteRemoteImg(string Str)
{
|