Exemplo n.º 1
0
 private void btnDowLoad_Click(object sender, EventArgs e)
 {
     ftpClient.download("/kythuat/KHUON_MAU/NHATKY_RAPKHUON.xlsx", "D:\\NHATKY_RAPKHUON.xlsx");
     if (ftpClient.message == "success")
     {
         MessageBox.Show(ftpClient.pathFileName + "success");
     }
     else
     {
         MessageBox.Show(ftpClient.message + "unsuccessful");
     }
 }
Exemplo n.º 2
0
 public void openPDFBanVe()
 {
     try
     {
         System.Diagnostics.Process          process   = new System.Diagnostics.Process();
         System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
         startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
         startInfo.FileName    = "cmd.exe";
         startInfo.Arguments   = "/c taskkill /f /im FoxitReader.exe";
         process.StartInfo     = startInfo;
         process.Start();
         Thread.Sleep(500);//chương trình ngủ
         //Xoa tat cac file pdf trong Appdomain giữ lại 1 file vừa mở
         string[] filePaths = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.PDF");
         foreach (string filePath in filePaths)
         {
             File.Delete(filePath);
         }
         string fileName   = this.filename + ".PDF";                //file cần download
         string sourcePath = this.pathname;                         //Đường dẫn file nguồn remote
         string targetPath = AppDomain.CurrentDomain.BaseDirectory; //Đường dẫn file đích local
         //Combine file và đường dẫn
         //string sourceFile = System.IO.Path.Combine(sourcePath, fileName); //combine file remote
         string sourceFile = string.Format(@"{0}/{1}", sourcePath, fileName);
         sourceFile = sourceFile.Replace(@"\\Server\", "");
         sourceFile = sourceFile.Replace(@"\", "/");
         string destFile = System.IO.Path.Combine(targetPath, fileName);//Combine file local
         //Console.WriteLine(sourceFile);
         //Console.WriteLine(destFile);
         //Download file từ file nguồn đến file đích
         //System.IO.File.Copy(sourceFile, destFile, true);
         ftpClient.download(sourceFile, destFile);
         BackgroundPDF(this.filename); //Ghi quyền vào file pdf vừa tải
         openpdf();                    //Mở file lên khi copy xong
     }
     catch (Exception ex)
     {
         Console.WriteLine("Không thành công: " + ex.Message);
     }
 }