Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstRemoteSiteFiles.SelectedItems[0] != null)
            {
                //Check if File or Folder
                if (lstRemoteSiteFiles.SelectedItems[0].SubItems[1].Text == "File")
                {
                    try
                    {
                        //Delete the FILE
                        FtpClient.FtpDelete(lstRemoteSiteFiles.SelectedItems[0].Text);
                    }
                    catch (Exception ex)
                    {
                        TaskDialog.Show("Error Occured while Deleting File.  Error Message: " + ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        //Delete the FOLDER
                        FtpClient.FtpDeleteDirectory(lstRemoteSiteFiles.SelectedItems[0].SubItems[2].Text);
                    }
                    catch (Exception ex)
                    {
                        TaskDialog.Show("Error Occured while Deleting File.  Error Message: " + ex.Message);
                    }
                }

                RefreshDirectory();
            }
        }