예제 #1
0
파일: Form1.cs 프로젝트: bangush/csharp
        private void Download(object userstate)
        {
            CallbackClass cc          = (CallbackClass)userstate;
            Uri           uri         = new Uri(cc.url);
            string        strFilePath = CreateStructure(Application.CommonAppDataPath + "\\" + uri.LocalPath.Replace("/", "\\"));
            WebClient     wc          = new WebClient();
            ListViewItem  lvi2;

            this.Invoke((MethodInvoker) delegate
            {
                lvi2 = FindListViewItem(cc.url);
                if (lvi2 != null)
                {
                    lvi2.SubItems[6].Text = strFilePath;
                }
            });
            wc.DownloadProgressChanged += (a, b) =>
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lvi2 = FindListViewItem(cc.url);
                    if (lvi2 != null)
                    {
                        //lvi2.SubItems[2].Text = b.BytesReceived.ToString();
                        lvi2.SubItems[5].Text = b.ProgressPercentage.ToString() + "%";
                        lvi2.SubItems[4].Text = (b.TotalBytesToReceive / 1024).ToString() + "kb";
                    }
                });
            };
            wc.DownloadFileCompleted += (a, b) =>
            {
                this.Invoke((MethodInvoker) delegate { });
            };
            wc.DownloadFileAsync(uri, strFilePath);
        }
예제 #2
0
파일: Form1.cs 프로젝트: bangush/csharp
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in listView1.SelectedItems)
     {
         string        url = lvi.SubItems[3].Text;
         CallbackClass obj = new CallbackClass(url);
         ThreadPool.QueueUserWorkItem((WaitCallback)Download, obj);
     }
 }
예제 #3
0
파일: Form1.cs 프로젝트: bangush/csharp
        private void GetRSS(object userstate)
        {
            CallbackClass obj = (CallbackClass)userstate;
            string        p   = obj.url;
            XmlDocument   xd  = new XmlDocument();

            xd.Load(p);
            foreach (XmlNode xn in xd.SelectNodes("//channel/item"))
            {
                bool bAdded = AddToArrayList(xn);
                if (bAdded)
                {
                    NewItemsFlag(p);
                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: Hagser/csharp
 private void downloadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in listView1.SelectedItems)
     {
         string url = lvi.SubItems[3].Text;
         CallbackClass obj = new CallbackClass(url);
         ThreadPool.QueueUserWorkItem((WaitCallback)Download, obj);
     }
 }