Example #1
0
 /// <summary>
 /// 在status页面生成对应的下载项列表
 /// </summary>
 /// <param name="dList"></param>
 /// <param name="folderPath"></param>
 private void setDownloadTab(string[] dList, string folderPath)
 {
     for (int i = 0; i < dList.Length; i++)
     {
         DownloadItemControl item = new DownloadItemControl(dList[i].ToString());
         item.Tag = dList[i].ToString();
         this.panel1.Controls.Add(item);
         item.Location = new Point(0, i * ITEM_HEIGHT);
         item.Show();
         itemList.Add(item.Tag, item);
     }
 }
Example #2
0
            /// <summary>
            /// 执行下载图片
            /// </summary>
            private void downloadPic(string[] dList, string folderPath)
            {
                for (int i = 0; i < dList.Length; i++)
                {
                    string url = dList[i];
                    if (url == "")
                    {
                        continue;
                    }
                    string picName  = url.Substring(url.LastIndexOf('/'));
                    string savePath = folderPath + picName;

                    DownloadItemControl item = (DownloadItemControl)itemList[url];
                    item.setDownloading();

                    try
                    {
                        WebRequest  request  = WebRequest.Create(url);
                        WebResponse response = request.GetResponse();
                        Stream      reader   = response.GetResponseStream();
                        FileStream  writer   = new FileStream(savePath, FileMode.OpenOrCreate, FileAccess.Write);
                        byte[]      buff     = new byte[512];
                        int         c        = 0; //实际读取的字节数
                        while ((c = reader.Read(buff, 0, buff.Length)) > 0)
                        {
                            writer.Write(buff, 0, c);
                        }
                        writer.Close();
                        writer.Dispose();

                        reader.Close();
                        reader.Dispose();
                        response.Close();
                        item.setDownloadComplete();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(url + "\n" + ex.Message, "Download Picture Error");
                        item.setDownloadFail();
                    }
                }
                MessageBox.Show("Download Completed");
            }
Example #3
0
 /// <summary>
 /// ��statusҳ�����ɶ�Ӧ���������б�
 /// </summary>
 /// <param name="dList"></param>
 /// <param name="folderPath"></param>
 private void setDownloadTab(string[] dList, string folderPath)
 {
     for(int i = 0; i < dList.Length; i++)
     {
         DownloadItemControl item = new DownloadItemControl(dList[i].ToString());
         item.Tag = dList[i].ToString();
         this.panel1.Controls.Add(item);
         item.Location = new Point(0, i * ITEM_HEIGHT);
         item.Show();
         itemList.Add(item.Tag, item);
     }
 }