Esempio n. 1
0
        public void downloadFile(string localpath, string webpath, ListView weblistview, UserInformation userinformation, FileInformationForListView.RefreshListViewSuccess refresh, UpYunLibrary.UpYun.SetProgressBar setprogressbar)
        {
            ArrayList filename = new ArrayList();//foldername = new ArrayList();

            for (int i = 0; i < weblistview.SelectedItems.Count; i++)
            {
                if (!weblistview.SelectedItems[i].SubItems[1].Text.Equals("0 B"))
                {
                    filename.Add(weblistview.SelectedItems[i].Text);
                }
            }

            fileinformationforlistview.downloadFile(localpath, webpath, filename, userinformation, refresh, setprogressbar);
        }
        public void downloadFileByUpYun(string localpath, string webpath, ArrayList filenamelist, UserInformation userinformation, FileInformationForListView.RefreshListViewSuccess refresh, UpYunLibrary.UpYun.SetProgressBar setprogressbar)
        {
            int        SelectNum = filenamelist.Count, count;
            FileStream Fs = null;

            try
            {
                for (int i = 0; i < SelectNum; i++)
                {
                    Fs = new FileStream(localpath + filenamelist[i], FileMode.Create);
                    string CopyLink = "";
                    if (userinformation.Url.Substring(userinformation.Url.Length - 1).Equals("/"))
                    {
                        CopyLink = userinformation.Url + webpath.Substring(1) + filenamelist[i];
                    }
                    else
                    {
                        CopyLink = userinformation.Url + "/" + webpath.Substring(1) + filenamelist[i];
                    }
                    HttpWebRequest         Hwr    = (HttpWebRequest)WebRequest.Create(CopyLink);
                    HttpWebResponse        rps    = (HttpWebResponse)Hwr.GetResponse();
                    Stream                 stream = rps.GetResponseStream();
                    byte[]                 byts   = new byte[rps.ContentLength];
                    System.Threading.Timer FileTm = new System.Threading.Timer(CalculateSpeedTime, null, 0, 1000);
                    while ((count = stream.Read(byts, 0, 5000)) != 0)
                    {
                        TempDataSize += count;
                        Fs.Write(byts, 0, count);
                        setprogressbar(false, filenamelist[i].ToString(), (Fs.Length / Convert.ToDouble(byts.Length)) * 100.0, TransSpeed);
                    }
                }
            }
            catch (Exception ex)
            {
                refresh(false);
                XtraMessageBox.Show(ex.ToString());
            }
            finally
            {
                refresh(true);
                Fs.Close();
            }
        }
Esempio n. 3
0
        public void upFileOrFolder(string webpath, string localpath, ListView locallistview, UserInformation userinformation, FileInformationForListView.RefreshListViewSuccess refresh, UpYunLibrary.UpYun.SetProgressBar setprogressbar)
        {
            ArrayList filename = new ArrayList();//foldername = new ArrayList();

            for (int i = 0; i < locallistview.SelectedItems.Count; i++)
            {
                if (!locallistview.SelectedItems[i].SubItems[1].Text.Equals("      "))
                {
                    filename.Add(locallistview.SelectedItems[i].Text);
                }
                //else
                //    foldername.Add(locallistview.Items[i].Text);
            }
            fileinformationforlistview.upFile(webpath, localpath, filename, userinformation, refresh, setprogressbar);
        }
        public void downloadFile(string localpath, string webpath, ArrayList filenamelist, UserInformation userinformation, FileInformationForListView.RefreshListViewSuccess refresh, UpYunLibrary.UpYun.SetProgressBar setprogressbar)
        {
            Thread thread = new Thread(() => downloadFileByUpYun(localpath, webpath, filenamelist, userinformation, refresh, setprogressbar));

            thread.IsBackground = true;
            thread.Start();
        }