Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.8k views
in Java FTP by
Suppose I have a folder called a on the FTPServer,in which there are a file called a.txt and another folder called.
1.
FTPFile[] fileList = ftp.directoryList("/f");
         for(int i=0; i<fileList.length; i++){
            System.out.println("The path is "+fileList[i].getPath());
         }

In situation 1,The output is "The path is ///f The path is ///f"
2.
ftp.changeDirectory("/f");
                     FTPFile[] fileList2 = ftp.directoryList();
         for(int i=0; i<fileList2.length; i++){
            System.out.println("The path is "+fileList2[i].getPath());
         }

In situation 2,The output is "The path is /f The path is /f"
I want to ask Why we get two different answers here:"///f" and "/f"
My OS is Windows XP SP3 Simplified Chinese Edition
The Server's OS is Windows XP SP2 Simplified Chinese Edition,and I am using CrossFTP 1.5

2 Answers

0 votes
by (162k points)
Could you post the log file from the first case?
0 votes
by
Here is the source code :
DMFTPClient ftp = new DMFTPClient();
      try{
         ftp.setRemoteHost("10.4.45.63");
         ftp.setRemotePort(2121);
         ftp.setUserName("user");
         ftp.setPassword("user");
         ftp.setControlEncoding("utf-8");
         ftp.connect();
         ftp.setEventListener(new EventListenerImpl_edtFTP());
         FTPFile[] fileList = ftp.directoryList("/f");
         for(int i=0; i<fileList.length; i++){
            System.out.println("The path is "+fileList[i].getPath());
         }
         ftp.changeDirectory("/f");
         FTPFile[] fileList2 = ftp.directoryList();
         for(int i=0; i<fileList2.length; i++){
            System.out.println("The path is "+fileList2[i].getPath());
         }
         ftp.disconnect();
      }catch(Exception e){
         e.printStackTrace();
      }
   }

And the comsole output is below
Cmmmond:---> SYST
Reply:215 UNIX Type: CrossFTP Server
Cmmmond:---> PWD
Reply:257 "/" is current directory.
Cmmmond:---> PORT 10,4,45,80,12,31
Reply:200 Command PORT okay.
Cmmmond:---> LIST /f
Reply:150 File status okay; about to open data connection.
Reply:226 Closing data connection.
The path is ///f
The path is ///f
Cmmmond:---> CWD /f
Reply:250 Directory changed to /f
Cmmmond:---> PWD
Reply:257 "/f" is current directory.
Cmmmond:---> PORT 10,4,45,80,12,32
Reply:200 Command PORT okay.
Cmmmond:---> LIST
Reply:150 File status okay; about to open data connection.
Reply:226 Closing data connection.
The path is /f
The path is /f
Cmmmond:---> QUIT
Reply:221 Goodbye.

Categories

...