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 newFolder(string foldername, string path, UserInformation userInformation) { fileinformationforlistview.newFolderForWeb(foldername, path, userInformation); }
public void getFileInformationWeb(ListView listview, ImageList imagelist, string path, UserInformation userInformation) { fileinformationforlistview.getFileInformationForListViewWeb(listview, imagelist, path, userInformation); }
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(); } }
public void rmFileForWeb(string webpath, UserInformation userinformation,ListView listview) { fileinformationforlistview.rmFile(webpath, userinformation, listview); }
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(); }
//public void upFolder(string webpath, string localpath, ArrayList foldername, UserInformation userinformation, RefreshListViewSuccess refresh, UpYunLibrary.UpYun.SetProgressBar setprogressbar) //{ //} public void upFileByUpYun(string localpath, string webpath, ArrayList filenamelist, UserInformation userinformation, RefreshListViewSuccess refresh, UpYunLibrary.UpYun.SetProgressBar setprogressbar) { int SelectNum = filenamelist.Count; try { for (int i = 0; i < SelectNum; i++) { string localpath_up = localpath + filenamelist[i]; FileStream fs = new FileStream(localpath_up, FileMode.Open, FileAccess.Read); BinaryReader r = new BinaryReader(fs); byte[] postArray = r.ReadBytes((int)fs.Length); string webpath_up = webpath + filenamelist[i]; userinformation.upYun.writeFile(webpath_up, postArray, true, setprogressbar); fs.Close(); } } catch (Exception ex) { refresh(false); XtraMessageBox.Show(ex.ToString(), "错误信息"); } refresh(true); }
/// <summary> /// Web删除文件 /// </summary> /// <param name="fullfoldername"></param> /// <param name="userinformation"></param> public void rmFile(string webpath, UserInformation userinformation,ListView listview) { for (int i = 0; i < listview.SelectedItems.Count;i++ ) { userinformation.upYun.deleteFile(webpath+listview.SelectedItems[i].Text); } }
/// <summary> /// Web新建文件夹 /// </summary> /// <param name="foldername"></param> /// <param name="path"></param> /// <param name="userinformation"></param> public void newFolderForWeb(string foldername,string path,UserInformation userinformation) { string fullfoldername = path + foldername; userinformation.upYun.mkDir(fullfoldername,true); }
/// <summary> /// 远程浏览器ListView填充数据 /// </summary> /// <param name="listview"></param> /// <param name="imagelist"></param> /// <param name="path"></param> /// <param name="userInformation"></param> public void getFileInformationForListViewWeb(ListView listview, ImageList imagelist, string path, UserInformation userInformation) { ArrayList str = new ArrayList(); try { str = userInformation.upYun.readDir(path); }catch{ } RefreshListViewWeb rlv = new RefreshListViewWeb(delegate(ListView dglistview, ImageList dgimagelist, string dgpath) { dglistview.BeginUpdate(); dglistview.Items.Clear(); dgimagelist.Images.Clear(); if (dgpath != @"/") dglistview.Items.Add("上级目录"); ListViewItem lvi = new ListViewItem(); int index = 1; dgimagelist.Images.Add("folder", ToolsLibrary.GetIcon.GetDirectoryIcon(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + @"\")); foreach (var item in str) { UpYunLibrary.FolderItem a = (UpYunLibrary.FolderItem)item; lvi = new ListViewItem(a.filename); if (a.filetype == "F") lvi.ImageIndex = 0; else if (a.filetype == "N") { lvi.ImageIndex = index; dgimagelist.Images.Add(a.filename, ToolsLibrary.GetIcon.GetFileIcon(a.filename, false)); index++; } lvi.SubItems.Add(ToolsLibrary.Tools.getCommonSize(a.size)); lvi.SubItems.Add(ToolsLibrary.Tools.getCommonTime(Convert.ToDouble(a.number)).ToString()); dglistview.Items.Add(lvi); } dglistview.EndUpdate(); }); listview.Invoke(rlv,listview,imagelist,path); }