Beispiel #1
0
        private void 添加到队列QToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String FolderPath = fbLocal.CurrentFolderPath;

            if (!Directory.Exists(FolderPath))
            {
                LogHelper.PushLog(String.Format("路径[{0}]不存在,无法下载!", FolderPath), Color.Red);
                return;
            }

            List <FtpBaseFileInfo> BaseFileList = new List <FtpBaseFileInfo>();

            foreach (ListViewItem tmpLvi in lvRemoteFile.SelectedItems)
            {
                BaseFileList.Add(tmpLvi.Tag as FtpBaseFileInfo);
            }

            foreach (var baseFile in BaseFileList)
            {
                var subItem = new TransferQueueItem(CurrentFtpClient);
                subItem.Type           = TransferQueueItem.TransferQueueItemTypeEnum.Download;
                subItem.RemoteBaseFile = baseFile;
                subItem.RemotePath     = baseFile.FullName;
                subItem.LocalPath      = Path.Combine(FolderPath, baseFile.Name);
                CurrentTransferQueue.AddToQueue(subItem);
            }
        }
Beispiel #2
0
        private void  除DToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var dr = MessageBox.Show("删除所选对象,你确定吗?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            List <FtpBaseFileInfo> BaseFileList = new List <FtpBaseFileInfo>();

            foreach (ListViewItem newLvi in lvRemoteFile.SelectedItems)
            {
                var baseFile = newLvi.Tag as FtpBaseFileInfo;
                BaseFileList.Add(baseFile);
            }
            foreach (FtpBaseFileInfo ftpBaseFileInfo in BaseFileList)
            {
                var subItem = new TransferQueueItem(CurrentFtpClient);
                subItem.Type           = TransferQueueItem.TransferQueueItemTypeEnum.Delete;
                subItem.RemoteBaseFile = ftpBaseFileInfo;
                subItem.RemotePath     = ftpBaseFileInfo.FullName;
                CurrentTransferQueue.AddToQueue(subItem);
            }
            CurrentTransferQueue.StartQueue();
            return;

            //原方法

            SetLvRemoteFileGray(true);
            //将删除远端路径线程加入线程池
            ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
            {
                String preWorkDirectory = CurrentFolderPath;
                //相关统计
                var DeletedFileCount     = 0;
                var DeletedFolderCount   = 0;
                var DeletedContentLength = 0L;
                var DeleteStartTime      = DateTime.Now;

                DeleteRemotePathList(BaseFileList, ref DeletedFileCount, ref DeletedFolderCount, ref DeletedContentLength);

                var LogStr = String.Format("已删除 {0} 个文件夹, {1} 个文件, 总计 {2} 于 {3} 秒。"
                                           , DeletedFolderCount
                                           , DeletedFileCount
                                           , storageUnitStringConverting.GetString(DeletedContentLength, 2, false) + "B"
                                           , (DateTime.Now - DeleteStartTime).TotalSeconds.ToString("N2")
                                           );
                LogHelper.PushLog(LogStr, Color.FromArgb(128, 0, 0));
                BeginListFolder(preWorkDirectory);
            }));
        }
Beispiel #3
0
        /*
         * private void TempUploadThread(Object obj)
         * {
         *  var strs = obj as String[];
         *  var localFilePath = strs[0];
         *  var remoteFileName = strs[1];
         *
         *  var ftpSite = CurrentFtpSiteData.GetFtpSite();
         *  ftpSite.UploadFile(remoteFileName, localFilePath);
         *  String logStr = String.Format("已传送: {0} {1} 于 {2} 秒 ({3}/秒)"
         *                              , remoteFileName
         *                              , IoHelper.GetFileLengthLevelString(ftpSite.TotalDataLength, 2)
         *                              , ftpSite.TransferUsedTime.TotalSeconds.ToString("N2")
         *                              , IoHelper.GetFileLengthLevelString(Convert.ToInt64(ftpSite.AverageTransferSpeed), 1));
         *  LogHelper.PushLog(logStr, Color.FromArgb(128, 0, 0));
         *  this.BeginInvoke(new ThreadHelper.UnnamedDelegate(delegate
         *  {
         *      HidenStatusToolStripItems();
         *  }));
         *  RefreshRemote();
         * }
         */

        private void lvServer_DragDrop(object sender, DragEventArgs e)
        {
            if (CurrentFtpClient == null)
            {
                return;
            }
            String[] PathArray = e.Data.GetData(DataFormats.FileDrop) as String[];

            foreach (var path in PathArray)
            {
                var subItem = new TransferQueueItem(CurrentFtpClient);
                subItem.Type       = TransferQueueItem.TransferQueueItemTypeEnum.Upload;
                subItem.LocalPath  = path;
                subItem.RemotePath = (CurrentFolderPath + "/" + IoHelper.GetFileOrFolderName(path, Path.DirectorySeparatorChar)).Replace("//", "/");
                CurrentTransferQueue.AddToQueue(subItem);
            }
            CurrentTransferQueue.StartQueue();
        }