Пример #1
0
        void tFtp_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            ConfigHandler conf = ConfigHandler.instance;
            FTPclient     ftp  = new FTPclient(conf.ftpHost, conf.ftpUserName, conf.ftpUserPassword);
            DirectoryInfo di   = new DirectoryInfo(ConfigHandler.instance.tempfolder);

            foreach (FileInfo f in di.GetFiles())
            {
                if (f.Length > ConfigHandler.instance.maximmiumValue)
                {
                    string fileName = String.Concat(ftp.CurrentDirectory, "/", f.Name);
                    bool   res      = ftp.Upload(f, fileName);
                    if (res)
                    {
                        f.Delete();
                    }
                }
            }
            string stmtFullPath = String.Concat(ftp.CurrentDirectory, conf.stmtFile);

            if (ftp.FtpFileExists(stmtFullPath))
            {
                string downPath = Path.Combine(conf.tempfolder, conf.stmtFile);
                ftp.Download(stmtFullPath, downPath, true);
                ftp.FtpDelete(stmtFullPath);
                //Bussiness Method
                ProcessStmtFile(downPath);
            }
        }
Пример #2
0
        public bool Download(Uri host, string fileName, string localFilename, bool permitOverwrite)
        {
            FTPclient ftp = new FTPclient(host.AbsoluteUri, FtpUser, FtpPassword);

            ftp.UsePassive = true;

            return(ftp.Download(fileName, localFilename, permitOverwrite));
        }
Пример #3
0
 void LoadImage(WPF.UCs.ImgBox pImage, string mylocalImage, string imgPath)
 {
     try
     {
         if (File.Exists(mylocalImage) && !m_blnForced2GetImagesFromFTP)
         {
             pImage.fullName = mylocalImage;
             pImage.LoadIMg();
             pImage.Tag = mylocalImage;
             return;
         }
         if (!string.IsNullOrEmpty(imgPath))
         {
             if (!PropertyLib._FTPProperties.IamLocal || m_blnForced2GetImagesFromFTP)
             {
                 FtpClient.CurrentDirectory = string.Format("{0}{1}", _FtpClientCurrentDirectory,
                                                            objChitiet.IdChitietchidinh.ToString());
                 if (FtpClient.FtpFileExists(FtpClient.CurrentDirectory + imgPath))
                 {
                     string sPath1 = string.Format(@"{0}\{1}\{2}", _baseDirectory,
                                                   objChitiet.IdChitietchidinh.ToString(), imgPath);
                     Utility.CreateFolder(sPath1);
                     FtpClient.Download(imgPath, sPath1, true);
                     pImage.fullName = sPath1;
                     pImage.LoadIMg();
                     pImage.Tag = sPath1;
                 }
                 else
                 {
                     pImage.fullName = path + @"\Path\noimage.jpg";
                     pImage.LoadIMg();
                     pImage.Tag = "";
                 }
             }
             else//Ảnh trên chính máy tính này
             {
                 pImage.fullName = imgPath;
                 pImage.LoadIMg();
                 pImage.Tag = imgPath;
             }
         }
     }
     catch
     {
     }
     finally
     {
         if (pImage._img.Source == null)
         {
             pImage.fullName = path + @"\Path\noimage.jpg";
             pImage.LoadIMg();
             pImage.Tag = "";
         }
     }
 }
Пример #4
0
        /// <summary>
        /// frmDownload constructor
        /// </summary>
        /// <param name="Filename">Name of the File to Download</param>
        /// <param name="Current_Directory">Current Directory of the FTPClient; where file will be downloaded from.</param>
        /// <param name="SavePath">Path where the File will be saved.</param>
        /// <param name="Ftpclient">FTPClient from frmMain that will be refrenced here to FtpClient variable.</param>
        public frmDownload(string Filename, string Current_Directory, string SavePath, FTPclient Ftpclient)
        {
            //Init Form
            InitializeComponent();

            //Setup Variables
            FileName             = Filename;
            SaveFilePath         = SavePath;
            CurrentDirectory     = Current_Directory;
            lblDownloadFrom.Text = Ftpclient.Hostname + Current_Directory + FileName;   //ex: ftp://ftp.somesite.com/current_dir/File.exe
            lblSavePath.Text     = SaveFilePath;
            FtpClient            = Ftpclient;
            TaskBarManager.ClearProgressValue();

            //Aero Composition Event
            AeroGlassCompositionChanged += new AeroGlassCompositionChangedEvent(Form1_AeroGlassCompositionChanged);

            if (AeroGlassCompositionEnabled)
            {
                //We don't want pnlNonTransparent and the controls in it to be part of AERO
                //but we do want Aero...looks cool ;)
                ExcludeControlFromAeroGlass(pnlNonTransparent);
            }
            else
            {
                this.BackColor = Color.Teal;
            }

            //Show Form
            this.Show();

            //Setup our Download Client and Start Downloading
            FtpClient.CurrentDirectory           = Current_Directory;
            FtpClient.OnDownloadProgressChanged += new FTPclient.DownloadProgressChangedHandler(FtpClient_OnDownloadProgressChanged);
            FtpClient.OnDownloadCompleted       += new FTPclient.DownloadCompletedHandler(FtpClient_OnDownloadCompleted);
            FtpClient.Download(FileName, SavePath, true);
        }