asked on
FTPClient ftp = new FTPClient();
source = frmFtpFormS.getFileSource();
destination = rs.getProperty("file_destination");
server = frmFtpFormS.getServerName();
username = frmFtpFormS.getFtpUsername();
password = frmFtpFormS.getFtpPassword();
/*Connect through FTPServer instead of FTP Client */
//ftp.setConnectTimeout(1000); // one second
ftp.connect(server);
ftp.login(username, password);//Login using Username and Password
/* To check Connect */
int reply = ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
// System.exit(1);
// getFTPStatus1("disconnect");
}
else
{
//getFTPStatus1("connect");
frmFtpFormS.setFtpcon("true");
// checkFtpCon="true";
}
ftp.changeWorkingDirectory(source);//change to the directory contaning files
String name = ftp.getSystemName();
/*
* Mode to connect with FTP Server
*
* */
//ftp.enterLocalPassiveMode();
ftp.enterLocalActiveMode();
String[] file1 = ftp.listNames();
FTPFile[] files = ftp.listFiles();// List the files in the directory
int l = files.length;