- 分享
- 0
- 人气
- 0
- 主题
- 62
- 帖子
- 6367
- UID
- 51295
- 积分
- 3715
- 阅读权限
- 21
- 注册时间
- 2006-11-21
- 最后登录
- 2022-1-19
- 在线时间
- 3699 小时
|
{"Exception has been thrown by the target of an invocation."}
在Application.Run();
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Net;
- namespace Skydrive_Linkgen
- {
- public partial class Main : Form
- {
- public Main()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- WebClient client = new WebClient();
- client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
- client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
- // Starts the download
- client.DownloadFileAsync(new Uri("http://cid-9c4752bf5eb398a9.skydrive.live.com/self.aspx/Public/MapleStory2.5D/Maplestory25D.Alpha2.7z"), "tmp.tmp");
- }
- void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- double bytesIn = double.Parse(e.BytesReceived.ToString());
- double totalBytes = double.Parse(e.TotalBytesToReceive.ToString());
- double percentage = bytesIn / totalBytes * 100;
- progressBar1.Value = int.Parse(Math.Truncate(percentage).ToString());
- }
- void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- string keyword = "<a id=\"spPreviewLink\" href=\"";
- System.IO.StreamReader SR = new System.IO.StreamReader("tmp.tmp");
- string[] line = SR.ReadToEnd().Split(Environment.NewLine.ToCharArray());
- string dta = null;
- for (int i = 0; i < line.Length; i++)
- {
- if (line[i].Contains(keyword))
- {
- dta = line[i].ToString();
- dta.Replace("\" rel=\"nofollow\" target=\"\" title=\"Download\">", "");
- dta = dta.Replace(keyword, "");
- dta = dta.Replace(":", ":");
- dta = dta.Replace("/", "/");
- dta = dta.Replace("?", "/");
- }
- }
- ListViewItem lst = new ListViewItem(System.IO.Path.GetFileName(dta.Replace("?download","")));
- lst.SubItems.Add(dta);
- listView1.Items.Add(lst);
- }
- private void Main_Load(object sender, EventArgs e)
- {
- }
- private void copyDownloadLinkToolStripMenuItem_Click(object sender, EventArgs e)
- {
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- if (listView1.Items[i].Selected = true)
- {
- Clipboard.SetText(listView1.Items[i].Text);
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
复制代码 |
|