using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Net;
using System.Threading;namespace CSharpControl02
{
class Program
{
static void Main(string[] args)
{
StringBuilder buidler = new StringBuilder();
buidler.AppendLine("http://avatar.profile.csdn.net/3/1/3/2_onmyway123456.jpg|a.jpg");
buidler.AppendLine("http://img1.gtimg.com/news/pics/hv1/13/147/550/35801248.jpg|b.jpg");
buidler.AppendLine("http://img1.gtimg.com/news/pics/hv1/85/142/550/35800045.jpg|c.jpg");
Console.WriteLine(buidler.ToString());
MatchCollection mc = Regex.Matches(buidler.ToString(), @"(?<url>[^|]*)\|(?<path>[^\r\n]+)");
for(int i=0;i<mc.Count;i++)
{
Match m = mc[i];
new Thread(() =>
{
Console.WriteLine("开始下载:\r\n" + m.Groups["url"].Value);
new WebClient().DownloadFile(m.Groups["url"].Value, m.Groups["path"].Value);
Console.WriteLine("下载完毕:\r\n" + m.Groups["url"].Value);
}).Start();
}
Console.ReadKey();
}
}
}
你写的看不懂。按你的意思写了一个。新建控制台程序,用上面代码替换program.cs文件中内容就可以看到结果。
http://www.easygeteasy.com