在土司论坛看到的,测试了一下很好用,以后下载工具资料什么的就方便了
代码如下
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; using System.IO; using System.Text.RegularExpressions; namespace csdn { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void getpage() { string Url = downurl.Text; string [] sun = Url.Split( '/' ); string id = sun[sun.Length - 1]; WebClient Client = new WebClient(); Client.Credentials = CredentialCache.DefaultCredentials; byte [] PageData = Client.DownloadData(@Url); string data = Encoding.UTF8.GetString(PageData); int a = data.IndexOf( "http:\\/\\/" ); int b=data.IndexOf( "\"}" ); string temp=data.Substring(a,b-a); temp = temp.Replace( "\\" , "" ); webBrowser1.Navigate(temp); } private void button1_Click( object sender, EventArgs e) { getpage(); } } } |
贴个下载地址:http://pan.baidu.com/share/link?shareid=401661&uk=3707994908