0 votes
by (160 points)

Hi!

I am connecting to a BulletProof FTP Server (2019.0.50) which is hosted on a Windows 2012 server. Every time I search for files in a folder, even though there are files on the server, GetList() method always returns 0 as the count. What might be the issue? I tried using the latest version (trial) and still no luck. Any guidance will be really appreciated.

var asnFileList = ftp.GetList("*.XML");
if (asnFileList.Count == 0)
{
    Console.WriteLine("No ASN files found.");
}
else
{
    Console.WriteLine($"[{asnFileList.Count}] new ASN files found.");
}

Log

2020-08-13 09:25:12.489 Opening log file.
2020-08-13 09:25:12.498 INFO FileLogWriter(1)[1] Info: Assembly: Rebex.Common 2020 R3 for .NET 4.6-4.8
2020-08-13 09:25:14.555 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |46-45-41-54-0D-0A | FEAT..
2020-08-13 09:25:14.555 INFO Ftp(1)[1] Command: FEAT
2020-08-13 09:25:14.561 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 | 211-Extensions s
0010 | upported:.. HOST
0020 | .. SIZE.. REST S
0030 | TREAM.. MDTM.. M
0040 | DTM YYYYMMDDHHMM
0050 | SS[+-TZ] filenam
0060 | e.. MLST size;t
0070 | ype
;perm;creat
0080 | e
;modify;.. MF
0090 | MT.. MD5.. XCRC
00A0 | "filename" start
00B0 | end.. XMD5 "fil
00C0 | ename" start end
00D0 | .. CLNT.. SITE I
00E0 | NDEX;ZONE;MSG;EX
00F0 | EC;PSWD.. COMB..
0100 | MODE Z.. UTF8..
0110 | LANG EN
.. OPTS
0120 | MODE;UTF8;..211
0130 | END..
09:25:14.561 INFO Ftp(1)[1] Response: 211-Extensions supported:
09:25:14.561 INFO Ftp(1)[1] Response: HOST
09:25:14.561 INFO Ftp(1)[1] Response: SIZE
09:25:14.561 INFO Ftp(1)[1] Response: REST STREAM
09:25:14.561 INFO Ftp(1)[1] Response: MDTM
09:25:14.561 INFO Ftp(1)[1] Response: MDTM YYYYMMDDHHMMSS[+-TZ] filename
09:25:14.561 INFO Ftp(1)[1] Response: MLST size;type;perm;create;modify*;
09:25:14.561 INFO Ftp(1)[1] Response: MFMT
09:25:14.561 INFO Ftp(1)[1] Response: MD5
09:25:14.561 INFO Ftp(1)[1] Response: XCRC "filename" start end
09:25:14.561 INFO Ftp(1)[1] Response: XMD5 "filename" start end
09:25:14.561 INFO Ftp(1)[1] Response: CLNT
09:25:14.561 INFO Ftp(1)[1] Response: SITE INDEX;ZONE;MSG;EXEC;PSWD
09:25:14.561 INFO Ftp(1)[1] Response: COMB
09:25:14.561 INFO Ftp(1)[1] Response: MODE Z
09:25:14.561 INFO Ftp(1)[1] Response: UTF8
09:25:14.561 INFO Ftp(1)[1] Response: LANG EN*
09:25:14.561 INFO Ftp(1)[1] Response: OPTS MODE;UTF8;
09:25:14.561 INFO Ftp(1)[1] Response: 211 END
09:25:14.564 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |53-59-53-54-0D-0A | SYST..
09:25:14.564 INFO Ftp(1)[1] Command: SYST
09:25:14.566 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-31-35-20-55-4E-49-58 20-54-79-70-65-3A-20-4C| 215 UNIX Type: L
0010 |38-20-49-6E-74-65-72-6E 65-74-20-43-6F-6D-70-6F| 8 Internet Compo
0020 |6E-65-6E-74-20-53-75-69 74-65-0D-0A | nent Suite..
09:25:14.566 INFO Ftp(1)[1] Response: 215 UNIX Type: L8 Internet Component Suite
09:25:14.567 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |4F-50-54-53-20-55-54-46 38-20-4F-4E-0D-0A | OPTS UTF8 ON..
09:25:14.567 INFO Ftp(1)[1] Command: OPTS UTF8 ON
09:25:14.569 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-30-30-20-55-54-46-38 20-4F-4E-20-4F-6B-2E-0D| 200 UTF8 ON Ok..
0010 |0A | .
09:25:14.569 INFO Ftp(1)[1] Response: 200 UTF8 ON Ok.
09:25:14.683 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |43-57-44-20-2F-46-50-49 2F-46-50-49-5F-54-45-53| CWD /FPI/FPITES
0010 |54-2F-44-4F-57-4E-0D-0A | T/DOWN..
09:25:14.683 INFO Ftp(1)[1] Command: CWD /FPI/FPI
TEST/DOWN
09:25:14.686 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-35-30-20-43-57-44-20 63-6F-6D-6D-61-6E-64-20| 250 CWD command
0010 |73-75-63-63-65-73-73-66 75-6C-2E-20-22-2F-46-50| successful. "/FP
0020 |49-2F-46-50-49-5F-54-45 53-54-2F-44-4F-57-4E-22| I/FPITEST/DOWN"
0030 |20-69-73-20-63-75-72-72 65-6E-74-20-64-69-72-65| is current dire
0040 |63-74-6F-72-79-2E-0D-0A | ctory...
09:25:14.844 DEBUG Ftp(1)[1] Info: Starting data transfer.
09:25:14.844 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |54-59-50-45-20-41-0D-0A | TYPE A..
09:25:14.844 INFO Ftp(1)[1] Command: TYPE A
09:25:14.847 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-30-30-20-54-79-70-65 20-73-65-74-20-74-6F-20| 200 Type set to
0010 |41-2E-0D-0A | A...
09:25:14.847 INFO Ftp(1)[1] Response: 200 Type set to A.
09:25:14.850 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |50-41-53-56-0D-0A | PASV..
09:25:14.850 INFO Ftp(1)[1] Command: PASV
09:25:14.853 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-32-37-20-45-6E-74-65 72-69-6E-67-20-50-61-73| 227 Entering Pas
0010 |73-69-76-65-20-4D-6F-64 65-20-28-31-30-2C-37-35| sive Mode (10,75
0020 |2C-32-30-2C-31-35-2C-31 31-37-2C-36-36-29-2E-0D| ,20,15,117,66)..
0030 |0A | .
09:25:14.857 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |4D-4C-53-44-20-2A-2E-58 4D-4C-0D-0A | MLSD *.XML..
09:25:14.857 INFO Ftp(1)[1] Command: MLSD *.XML
09:25:14.863 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |31-35-30-20-4F-70-65-6E 69-6E-67-20-64-61-74-61| 150 Opening data
0010 |20-63-6F-6E-6E-65-63-74 69-6F-6E-20-66-6F-72-20| connection for
0020 |64-69-72-65-63-74-6F-72 79-20-6C-69-73-74-2E-0D| directory list..
0030 |0A | .
09:25:14.864 INFO Ftp(1)[1] Response: 150 Opening data connection for directory list.
09:25:14.864 DEBUG Ftp(1)[1] Info: Data transfer started.
09:25:14.866 VERBOSE Ftp(1)[1] Info: Checking incoming data.
09:25:14.868 VERBOSE Ftp(1)[1] Info: Received 383 bytes of data through data connection.
09:25:14.868 DEBUG Ftp(1)[1] Info: Item: -rw-r--r-- 1 ftp ftp 4518 Apr 08 00:07 Duplicate
ASN23925523202004081724.XML
09:25:14.872 DEBUG Ftp(1)[1] Info: Item: -rw-r--r-- 1 ftp ftp 0 Mar 23 13:02 DuplicateASN25028637202003230907.XML
09:25:14.872 DEBUG Ftp(1)[1] Info: Item: -rw-r--r-- 1 ftp ftp 4518 Apr 11 23:12 Duplicate
ASN25037934202004120819.XML
09:25:14.872 DEBUG Ftp(1)[1] Info: Item: -rw-r--r-- 1 ftp ftp 17068 Apr 13 12:08 DuplicateASN2661039_202004131628.XML
09:25:14.873 VERBOSE Ftp(1)[1] Info: Checking incoming data.
09:25:14.873 DEBUG Ftp(1)[1] Info: Data transfer ended. 383 bytes transferred.
09:25:14.875 DEBUG Ftp(1)[1] Info: Closing downloading data connection.
09:25:14.877 DEBUG Ftp(1)[1] Info: Waiting for data transfer ending message.
09:25:14.919 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-32-36-20-46-69-6C-65 20-73-65-6E-74-20-6F-6B| 226 File sent ok
0010 |0D-0A | ..
09:25:14.919 INFO Ftp(1)[1] Response: 226 File sent ok
09:25:14.920 DEBUG Ftp(1)[1] Info: Data transfer ended.
09:25:14.920 DEBUG Ftp(1)[1] Info: Transfer ended successfully.
09:25:14.920 DEBUG Ftp(1)[1] Info: Data connection closed.
09:25:17.369 VERBOSE Ftp(1)[1] Info: Sent data over control connection:
0000 |51-55-49-54-0D-0A | QUIT..
09:25:17.369 INFO Ftp(1)[1] Command: QUIT
09:25:17.371 VERBOSE Ftp(1)[1] Info: Received data over control connection:
0000 |32-32-31-20-47-6F-6F-64 62-79-65-2E-0D-0A | 221 Goodbye...
09:25:17.371 INFO Ftp(1)[1] Response: 221 Goodbye.

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
by (144k points)
selected by
 
Best answer

The Ftp.GetList(string) method is somewhat problematic. This is from the API documentation:

Caution: The meaning of the arguments argument is not defined by RFC and varies from server to server. Some servers interpret it as parameters to dir command, some as a filename, some ignore it and some report an error. Calling this method with arguments other than null is not recommended and will make your code incompatible with many FTP servers.

One possible workaround for this involves temporarily disabling MLSD command support, making the GetList method revert to LIST command, which might work:

ftp.EnabledExtensions &= ~FtpExtensions.MachineProcessingList;
var list = ftp.GetList("*.XML");
ftp.EnabledExtensions |= FtpExtensions.MachineProcessingList;
...

However, if this doesn't work, that would mean the server does not support wildcard-based file name arguments (it might interpret the argument as a directory path instead), and that you would have to retrieve the whole list and filter it at the client side:

var list = ftp.GetList("*");
string[] files = list.GetFiles("*.XML");
...
by (160 points)
Thank you for the explanation and two alternatives. I tried both and the only way it worked was by disabling MLSD command.

Thanks!
...