Hi,
I need to transfer files back and forth between localhosts and a ftp-server. I am using Jakartas Common Not 1.4.1.
I have no problem connecting and transfering files. The problem I have is, that once I have set the working directory of the ftp-connection, I cannot use changeWorkingDirectory(String str) to change it. The only change that works is changeToParentDirectory.
Can it be a trouble with the server? Or do I have some flaws in my implementation?
try{
FTPClient ftp = new FTPClient();
ftp.connect(this.host);
ftp.login(this.username, this.password);
FileInputStream in = new FileInputStream(new File("C:\\workflow.JPG"));
ftp.changeWorkingDirectory("root/firstDir/");
ftp.appendFile("inFirstDir.jpg", (InputStream)in );
ftp.changeWorkingDirectory("root/secondDir/");
//ftp.changeToParentDirectory();
ftp.appendFile("inSecondtDir.jpg", (InputStream)in );
}catch(Exception e){
System.err.println("Error");
}
If I run the code above it results in both files ending up in root/firstDir. I thought the second file would end up in root/secondDir.
If I instead use changeToParentDirectory(), the second file, inSecondtDir.jpg, ends up in the root/.
Am I supposed to disconnect and reconnect each time I want to go to a directory that is a child or a sibling to my first/current working directory?
I am quite new to the FTP-protocol...
thanks,
Jerfa