Пример #1
0
        ///// <summary>
        ///// 显示进度条
        ///// </summary>
        //private ControlProgressBar ShowProgressBar(bool upOrDown, string sourceFilePath, string targetFilePath)
        //{
        //    ControlProgressBar progressBar = trafficManager.AddProgressBar(upOrDown?"UP":"DOWN");
        //    progressBar.TextSourceInfo = sourceFilePath;
        //    progressBar.TextTargetInfo = targetFilePath;
        //    progressBar.TextStatus = upOrDown?"uping":"downing";
        //    trafficManager.Show();
        //    return progressBar;
        //}
        //private void ShowPercentageInProgressBar(Alt_ProgressChangedEventArgs e)
        //{
        //    ControlProgressBar progressBar = e.UserState as ControlProgressBar;
        //    progressBar.Value = e.ProgressPercentage;
        //}
        //private void ShowResultInProgressBar(bool isSuccess,AltCompletedEventArgs e)
        //{
        //    ControlProgressBar progressBar = e.UserState as ControlProgressBar;
        //    progressBar.TextStatus =isSuccess?"successed":"failed";
        //}


        /// <summary>
        /// 下载文件
        /// </summary>
        private void DownloadFile(string sourceFilePath, string targetFilePath)
        {
            try
            {
                ////判断窗体是否已经被关闭
                //if (trafficManager == null || trafficManager.IsDisposed)
                //{
                //    trafficManager = new FormTrafficManager();
                //}
                //ControlProgressBar progressBar = ShowProgressBar(false, sourceFilePath, targetFilePath);
                //FileUploadOrDownload download = new FileUploadOrDownload(_shellData, sourceFilePath, targetFilePath);
                //download.DownloadFileProgressChangedToDo += download_DownloadFileProgressChangedToDo;
                //download.DownloadFileCompletedToDo+=download_DownloadFileCompletedToDo;
                //download.StartToDownloadFile();
                FileUploadOrDownload download = new FileUploadOrDownload(_hostService, _shellData, sourceFilePath, targetFilePath);
                download.DownloadFileProgressChangedToDo += download_DownloadFileProgressChangedToDo;
                download.DownloadFileCompletedToDo       += download_DownloadFileCompletedToDo;
                download.StartToDownloadFile();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #2
0
 /// <summary>
 /// 上传文件
 /// </summary>
 private void UploadFile(string sourceFilePath, string targetFilePath)
 {
     try
     {
         //判断窗体是否已经被关闭
         //if (trafficManager == null || trafficManager.IsDisposed)
         //{
         //    trafficManager = new FormTrafficManager();
         //}
         //ControlProgressBar progressBar = ShowProgressBar(true, sourceFilePath, targetFilePath);
         //FileUploadOrDownload upload = new FileUploadOrDownload(_shellData, sourceFilePath, targetFilePath);
         //upload.UploadFileProgressChangedToDo += upload_UploadFileProgressChangedToDo;
         //upload.UploadFileCompletedToDo += upload_UploadFileCompletedToDo;
         //upload.StartToUploadFile();
         FileUploadOrDownload upload = new FileUploadOrDownload(_hostService, _shellData, sourceFilePath, targetFilePath);
         upload.UploadFileProgressChangedToDo += upload_UploadFileProgressChangedToDo;
         upload.UploadFileCompletedToDo += upload_UploadFileCompletedToDo;
         upload.StartToUploadFile();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }