0 votes
by (160 points)
edited

Hello! We have a problem with FTP component. Consider this ftp site structure:

root
-> Dir with space
   -> file with space.txt
...

When using Ftp.GetList() recursively, we will never see the file in its results.

On the other hand standard windows ftp client (as well as win explorer) can reach the file without any problems.

Could you please point me to a solution or fix this bug.

Version of Rebex.Net.Ftp.dll is 3.0.3793.0 I've also tried 3.0.3854.0 with the same result

Thanks in advance.

Igor.

Below is some output from different tools

----Standard windows ftp console----


ftp> ls "//Dir with space"  
200 PORT command successful.  
150 Opening ASCII mode data connection for 'file list'.  
//Dir with space/Internet Explorer.rar  
226 Transfer complete.  
ftp: 40 bytes received in 0.00Seconds 40.00Kbytes/sec.  
ftp> cd "Dir with space"  
250 CWD command successful.  
ftp> ls  
200 PORT command successful.  
150 Opening ASCII mode data connection for 'file list'.  
Internet Explorer.rar  
226 Transfer complete.  
ftp: 23 bytes received in 0.00Seconds 23000.00Kbytes/sec.

----Complete output from Rebex console client----


211- Extensions supported:  
 MDTM  
 REST STREAM  
 SIZE  
211 End.  
ftp> ls "//Dir with space"  
200 Type set to A.  
227 Entering Passive Mode (85,12,57,68,236,71)  
150 Opening ASCII mode data connection for '/bin/ls'.  
226 Transfer complete.  
Dir with space  
ftp> cd "Dir with space"  
550 "Dir with space": No such file or directory. 

----Log of our test application - level = Verbose----


2010-07-27 17:40:04.918 Opening log file.  
2010-07-27 17:40:04.936 INFO Ftp(1) Info: Connecting to **********:21 using Ftp 3.0.3793.0.  
2010-07-27 17:40:04.937 INFO Ftp(1) Info: Using proxy none.  
2010-07-27 17:40:05.025 DEBUG Ftp(1) Info: Connection succeeded.  
2010-07-27 17:40:05.079 VERBOSE Ftp(1) Info: Received data over control connection:   
    32-32-30-20-46-54-50-20-73-65-72-76-65-72-20-72-65-61-64-79-2E-0D-0A  
2010-07-27 17:40:05.079 VERBOSE Ftp(1) Info: Response available to be received on control   connection.  
2010-07-27 17:40:05.081 INFO Ftp(1) Response: 220 FTP server ready.  
2010-07-27 17:40:05.096 VERBOSE Ftp(1) Info: Sent data over control connection:   
    55-53-45-52-20-77-6C-2D-54-65-73-74-41-63-63-0D-0A  
2010-07-27 17:40:05.097 INFO Ftp(1) Command: USER ******  
2010-07-27 17:40:05.157 VERBOSE Ftp(1) Info: Received data over control connection:   
    33-33-31-20-50-61-73-73-77-6F-72-64-20-72-65-71-75-69-72-65-64-20-66-6F  
    72-20-77-6C-2D-54-65-73-74-41-63-63-2E-0D-0A  
2010-07-27 17:40:05.157 VERBOSE Ftp(1) Info: Response available to be received on control   connection.  
2010-07-27 17:40:05.157 INFO Ftp(1) Response: 331 Password required for ******.  
2010-07-27 17:40:05.160 VERBOSE Ftp(1) Info: Sent data over control connection:   
    50-41-53-53-20-76-76-49-66-71-52-68-70-39-4A-0D-0A  
2010-07-27 17:40:05.160 INFO Ftp(1) Command: PASS **********  
2010-07-27 17:40:05.234 VERBOSE Ftp(1) Info: Received data over control connection:   
    32-33-30-20-55-73-65-72-20-77-6C-2D-54-65-73-74-41-63-63-20-6C-6F-67-67  
    65-64-20-69-6E-2C-20-61-63-63-65-73-73-20-72-65-73-74-72-69-63-74-69-6F  
    6E-73-20-61-70-70-6C-79-2E-0D-0A  
2010-07-27 17:40:05.234 VERBOSE Ftp(1) Info: Response available to be received on control   connection.  
2010-07-27 17:40:05.234 INFO Ftp(1) Response: 230 User ****** logged in, access   restrictions apply.  
2010-07-27 17:40:05.236 VERBOSE Ftp(1) Info: Sent data over control connection:   
    46-45-41-54-0D-0A  
2010-07-27 17:40:05.236 INFO Ftp(1) Command: FEAT  
2010-07-27 17:40:05.296 VERBOSE Ftp(1) Info: Received data over control connection:   
    32-31-31-2D-20-45-78-74-65-6E-73-69-6F-6E-73-20-73-75-70-70-6F-72-74-65  
    64-3A-0D-0A  
2010-07-27 17:40:05.296 VERBOSE Ftp(1) Info: Response available to be received on control   connection.  
2010-07-27 17:40:05.296 INFO Ftp(1) Response: 211- Extensions supported:  
2010-07-27 17:40:05.296 VERBOSE Ftp(1) Info: Received data over control connection:   
    20-4D-44-54-4D-0D-0A-20-52-45-53-54-20-53-54-52-45-41-4D-0D-0A-20-53-49  
    5A-45-0D-0A-32-31-31-20-45-6E-64-2E-0D-0A  
2010-07-27 17:40:05.296 VERBOSE Ftp(1) Info: Response available to be received on control connection.  
2010-07-27 17:40:05.296 INFO Ftp(1) Response:  MDTM  
2010-07-27 17:40:05.296 INFO Ftp(1) Response:  REST STREAM  
2010-07-27 17:40:05.296 INFO Ftp(1) Response:  SIZE  
2010-07-27 17:40:05.296 INFO Ftp(1) Response: 211 End.  
2010-07-27 17:40:05.352 DEBUG Ftp(1) Info: Starting data transfer.  
2010-07-27 17:40:05.353 VERBOSE Ftp(1) Info: Sent data over control connection:   
    54-59-50-45-20-49-0D-0A  
2010-07-27 17:40:05.353 INFO Ftp(1) Command: TYPE I  
2010-07-27 17:40:05.405 VERBOSE Ftp(1) Info: Received data over control connection:   
    32-30-30-20-54-79-70-65-20-73-65-74-20-74-6F-20-49-2E-0D-0A  
2010-07-27 17:40:05.405 VERBOSE Ftp(1) Info: Response available to be received on control connection.  
2010-07-27 17:40:05.405 INFO Ftp(1) Response: 200 Type set to I.  
2010-07-27 17:40:05.410 VERBOSE Ftp(1) Info: Sent data over control connection:   
    50-41-53-56-0D-0A  
2010-07-27 17:40:05.410 INFO Ftp(1) Command: PASV  
2010-07-27 17:40:05.463 VERBOSE Ftp(1) Info: Received data over control connection:   
    32-32-37-20-45-6E-74-65-72-69-6E-67-20-50-61-73-73-69-76-65-20-4D-6F-64  
    65-20-28-38-35-2C-31-32-2C-35-37-2C-36-38-2C-32-32-35-2C-31-39-31-29-0D  
    0A  
2010-07-27 17:40:05.463 VERBOSE Ftp(1) Info: Response available to be received on control connection.  
2010-07-27 17:40:05.464 INFO Ftp(1) Response: 227 Entering Passive Mode   (85,12,57,68,225,191)  
2010-07-27 17:40:05.470 DEBUG Ftp(1) Info: Establishing data connection to 85.12.57.68:57791.  
2010-07-27 17:40:05.531 VERBOSE Ftp(1) Info: Sent data over control connection:   
    4C-49-53-54-20-2F-2F-0D-0A  
2010-07-27 17:40:05.531 INFO Ftp(1) Command: LIST //  
2010-07-27 17:40:05.584 VERBOSE Ftp(1) Info: Received data over control connection: 
    31-35-30-20-4F-70-65-6E-69-6E-67-20-42-49-4E-41-52-59-20-6D-6F-64-65-20  
    64-61-74-61-20-63-6F-6E-6E-65-63-74-69-6F-6E-20-66-6F-72-20-27-2F-62-69  
    6E-2F-6C-73-27-2E-0D-0A  
2010-07-27 17:40:05.584 VERBOSE Ftp(1) Info: Response available to be received on control connection.  
2010-07-27 17:40:05.584 INFO Ftp(1) Response: 150 Opening BINARY mode data connection for '/bin/ls'.  
2010-07-27 17:40:05.589 VERBOSE Ftp(1) Info: Checking incoming data.  
2010-07-27 17:40:05.592 VERBOSE Ftp(1) Info: Received data over control connection: 
    32-32-36-20-54-72-61-6E-73-66-65-72-20-63-6F-6D-70-6C-65-74-65-2E-0D-0A  
2010-07-27 17:40:05.592 VERBOSE Ftp(1) Info: Response available to be received on control connection.  
2010-07-27 17:40:05.592 INFO Ftp(1) Response: 226 Transfer complete.  
2010-07-27 17:40:05.592 VERBOSE Ftp(1) Info: Received 65 bytes of data through data connection.  
2010-07-27 17:40:05.618 VERBOSE Ftp(1) Info: Checking incoming data.  
2010-07-27 17:40:05.618 DEBUG Ftp(1) Info: Data transfer ended.  
2010-07-27 17:40:05.621 DEBUG Ftp(1) Info: Closing downloading data connection.  
2010-07-27 17:40:05.625 DEBUG Ftp(1) Info: Transfer ended successfully.  
2010-07-27 17:40:05.625 DEBUG Ftp(1) Info: Data connection closed.  
2010-07-27 17:40:05.627 DEBUG Ftp(1) Info: Starting data transfer.  
2010-07-27 17:40:05.628 VERBOSE Ftp(1) Info: Sent data over control connection: 
    50-41-53-56-0D-0A  
2010-07-27 17:40:05.628 INFO Ftp(1) Command: PASV  
2010-07-27 17:40:05.682 VERBOSE Ftp(1) Info: Received data over control connection: 
    32-32-37-20-45-6E-74-65-72-69-6E-67-20-50-61-73-73-69-76-65-20-4D-6F-64  
    65-20-28-38-35-2C-31-32-2C-35-37-2C-36-38-2C-32-32-38-2C-32-32-36-29-0D  
    0A  
2010-07-27 17:40:05.
Applies to: Rebex FTP/SSL

3 Answers

0 votes
by (147k points)
edited

Have you tried passing the quotes (") character to GetList? Such as

client.GetList("\"Dir with space\"") // in C#
  • or -

    client.GetList("""Dir with space""") 'in VB.NET

?

The format of FTP protocol's LIST command arguments is not defined, so we don't do this ourselves.

0 votes
by (160 points)
edited

Unfortunately this easy solution does not work for concrete ftp server. Rebex ftp console client (one of samples delivered with the product) does not see the folder as well.

by (13.0k points)
Could you update the your question and include the log output and error message from situation when client.GetList("\"dir with space\"") syntax is used? Or mail it to support@rebex.net for analysis?
by (160 points)
Sure. It'll be in your mailbox shortly
+1 vote
by (13.0k points)
edited

Conversation continued over the email. I'm posting the summary here so it can help others in similar situation.

The original code look like this:

ftp.GetList(\""Dir with space\"")

and it returned the empty list.

The Windows command line client was able to list the directory content using the ls "Dir with space" command, but was unable to list the content using the dir "Dir with space" command.

The ls "Dir with space" in fact issues following FTP command sequence

NLST Dir with space

and dir "Dir with space" issues following FTP command sequence

LIST Dir with space

This specific FTP server supports listing directories with space in name as a parameter to NLST command, but does not support the same for the LIST command.

Workaround 1

Use the parameterless variant of GetList. It will return the full info about files (such as file sizes). It will use the LIST FTP command.

ftp.ChangeDirectory("\"Dir with space\"");
FtpList items = ftp.GetList();
ftp.ChangeDirectory("..");

Workaround 2

Use the NLST command. It will return only filenames with no additional info.

string[] items = ftp.GetNameList("Dir with space");

For more info on LIST and NLST command see question FTP and LIST/NLST commands

Solution

Update/reconfigure the FTP server so it can handle spaces in directory names in the LIST command.

...