private void tmrCopy_Tick(object sender, EventArgs e) { Properties.Settings.Default["src1"] = txtsrc1.Text; Properties.Settings.Default["dst1"] = txtdest1.Text; Properties.Settings.Default["ftp_host"] = txtftp_host.Text; Properties.Settings.Default["ftp_name"] = txtftp_name.Text; Properties.Settings.Default["ftp_pass"] = txtftp_pass.Text; Properties.Settings.Default.Save(); if (copy.Checked == false) { return; } string sourceDIR = txtsrc1.Text; string dests = txtdest1.Text; string ftpHost = txtftp_host.Text; string ftpName = txtftp_name.Text; string ftpPass = txtftp_pass.Text; try { DirectoryInfo src; try { if (!Directory.Exists(sourceDIR)) { Directory.CreateDirectory(sourceDIR); } if (!Directory.Exists(dests)) { Directory.CreateDirectory(dests); } } catch (Exception z) { DisableCopy(z.Message); } src = new DirectoryInfo(sourceDIR); //Console.WriteLine("{0} {1} {2} {3}", nowtime, ftpHost, ftpName, ftpPass); // create ftp object FTPconnection ftp = new FTPconnection(ftpHost, ftpName, ftpPass); bool connected = false; bool sent = false; FileInfo[] files = null; try { files = src.GetFiles(); //System.Console.WriteLine("FILES " + files.Length); if (files.Length > 0) { connected = ftp.testConnection(); } } catch (Exception z) { DisableCopy(z.Message); } // upload if ftp is good if (connected) { foreach (FileInfo file in files) { try { sent = false; try { sent = ftp.copyToServer(file.Name, file.FullName, dests); } catch (Exception z) { DisableCopy(z.Message); sent = false; } if (sent) { file.CopyTo(Path.Combine(dests, file.Name), true); file.Delete(); } } catch (Exception z) { DisableCopy(z.Message); } } } } catch (Exception z) { DisableCopy(z.Message); } }
private void tmrCopy_Tick(object sender, EventArgs e) { Properties.Settings.Default["src1"] = txtsrc1.Text; Properties.Settings.Default["dst1"] = txtdest1.Text; Properties.Settings.Default["ftp_host"] = txtftp_host.Text; Properties.Settings.Default["ftp_name"] = txtftp_name.Text; Properties.Settings.Default["ftp_pass"] = txtftp_pass.Text; Properties.Settings.Default.Save(); if (copy.Checked == false ) return; string sourceDIR = txtsrc1.Text; string dests = txtdest1.Text; string ftpHost = txtftp_host.Text; string ftpName = txtftp_name.Text; string ftpPass = txtftp_pass.Text; try { DirectoryInfo src; try { if (!Directory.Exists(sourceDIR)) { Directory.CreateDirectory(sourceDIR); } if (!Directory.Exists(dests)) { Directory.CreateDirectory(dests); } } catch (Exception z) { DisableCopy(z.Message); } src = new DirectoryInfo(sourceDIR); //Console.WriteLine("{0} {1} {2} {3}", nowtime, ftpHost, ftpName, ftpPass); // create ftp object FTPconnection ftp = new FTPconnection(ftpHost, ftpName, ftpPass); bool connected = false; bool sent = false; FileInfo[] files = null; try { files = src.GetFiles(); //System.Console.WriteLine("FILES " + files.Length); if (files.Length > 0) { connected = ftp.testConnection(); } } catch (Exception z) { DisableCopy(z.Message); } // upload if ftp is good if (connected) { foreach (FileInfo file in files) { try { sent = false; try { sent = ftp.copyToServer(file.Name, file.FullName, dests); } catch (Exception z) { DisableCopy(z.Message); sent = false; } if (sent) { file.CopyTo(Path.Combine(dests, file.Name), true); file.Delete(); } } catch (Exception z) { DisableCopy(z.Message); } } } } catch (Exception z) { DisableCopy(z.Message); } }