Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
8.7k views
in .NET FTP by (240 points)
I have a dotnet application which is using the EnterpriseDT FTP classes to connect to and download files from a remote FTP server. I have hit a problem where the GET command fails with a 550 Failed To Open File error when the filename to download has a space in it. The list of files to download is being retrieved via a Dir command within the FTP client.

I have tried wrapping the filename in " characters as you have to do from a DOS FTP client but this also does not work.

Does anyonew know if there is a way to FTP files with spaces in their names successfully using the Enterprise DT FTP classes?

7 Answers

0 votes
by (162k points)
connect via an FTP commandline client, type 'debug' and then get the file and post the resulting debug here.
0 votes
by (240 points)
Here is the debug from a command line client trying to get the file with and without wrapping the filename in quotes.


ftp> debug
Debugging On .
ftp> get "sample file pasted in.txt"
---> PORT 10,0,35,47,5,39
200 PORT command successful. Consider using PASV.
---> RETR sample file pasted in.txt
150 Opening BINARY mode data connection for sample file pasted in.txt (2 bytes).

226 File send OK.
ftp: 2 bytes received in 0.00Seconds 2000.00Kbytes/sec.
ftp> get sample file pasted in.txt
---> PORT 10,0,35,47,5,40
200 PORT command successful. Consider using PASV.
---> RETR sample
550 Failed to open file.
ftp>
0 votes
by (162k points)
ok, so it looks like the server understands spaces.

are you sure spaces are getting passed into edtFTPnet correctly? are you able to generate a log file that shows the commands? (see the help)
0 votes
by (240 points)
We have our own logging based on log4net structured into the application and have configured the FTP event handlers to log debug information. Below are 2 sections from the log when the application is trying to get a file with a space in the name, the first is with the name as per the passed in string and the in the second we amended the code to wrap the filename in quotes to try and fix the space issue. If you still need me to configure your own logging then please let me know.

2006-09-22 13:35:19,201 [3876] DEBUG - Entering Method:FileUtils.GetConnectedFTPClient
2006-09-22 13:35:19,201 [3876] DEBUG - Entering Method:DataAccess.GetParameterValue:pName='DFDUsername'
2006-09-22 13:35:19,201 [3876] DEBUG - Entering Method:DataAccess.GetParameterValue:pName='DFDPassword'
2006-09-22 13:35:19,201 [3876] DEBUG - Entering Method:DataAccess.GetParameterValue:pName='DFDIPAddress'
2006-09-22 13:35:19,217 [3876] DEBUG - FTPCommandSent:---> USER commercials
2006-09-22 13:35:19,217 [3876] DEBUG - FTPReplyReceived:331 Please specify the password.
2006-09-22 13:35:19,217 [3876] DEBUG - FTPCommandSent:---> PASS ********
2006-09-22 13:35:19,358 [3876] DEBUG - FTPReplyReceived:230 Login successful.
2006-09-22 13:35:19,358 [3876] DEBUG - FTPCommandSent:---> TYPE I
2006-09-22 13:35:19,358 [3876] DEBUG - FTPReplyReceived:200 Switching to Binary mode.
2006-09-22 13:35:19,358 [3876] DEBUG - FTPTransferStarted: LocalFile:C:\Program Files\Radio Direct\Holding\see m00018_02.xml|RemoteFile:see m00018_02.xml|Direction:DOWNLOAD|Type:BINARY
2006-09-22 13:35:19,358 [3876] DEBUG - FTPCommandSent:---> PASV
2006-09-22 13:35:19,358 [3876] DEBUG - FTPReplyReceived:227 Entering Passive Mode (10,216,8,151,63,105)
2006-09-22 13:35:19,358 [3876] DEBUG - FTPCommandSent:---> RETR see m00018_02.xml
2006-09-22 13:35:19,358 [3876] DEBUG - FTPReplyReceived:550 Failed to open file.



2006-09-26 10:42:55,466 [5628] DEBUG - Entering Method:FileUtils.GetFileFromDFD:pFilename='TEST 00029_02.xml'
2006-09-26 10:42:55,466 [5628] DEBUG - Entering Method:FileUtils.GetConnectedFTPClient
2006-09-26 10:42:55,466 [5628] DEBUG - Entering Method:DataAccess.GetParameterValue:pName='DFDUsername'
2006-09-26 10:42:55,482 [5628] DEBUG - Entering Method:DataAccess.GetParameterValue:pName='DFDPassword'
2006-09-26 10:42:55,497 [5628] DEBUG - Entering Method:DataAccess.GetParameterValue:pName='DFDIPAddress'
2006-09-26 10:42:55,529 [5628] DEBUG - FTPCommandSent:---> USER commercials
2006-09-26 10:42:55,529 [5628] DEBUG - FTPReplyReceived:331 Please specify the password.
2006-09-26 10:42:55,529 [5628] DEBUG - FTPCommandSent:---> PASS ********
2006-09-26 10:42:55,669 [5628] DEBUG - FTPReplyReceived:230 Login successful.
2006-09-26 10:42:55,669 [5628] DEBUG - FTPCommandSent:---> TYPE I
2006-09-26 10:42:55,669 [5628] DEBUG - FTPReplyReceived:200 Switching to Binary mode.
2006-09-26 10:42:55,669 [5628] DEBUG - FTPTransferStarted: LocalFile:C:\sslocal\Code\IRN\RadioDirect\Station Console\Console Application\bin\Holding\TEST 00029_02.xml|RemoteFile:"TEST 00029_02.xml"|Direction:DOWNLOAD|Type:BINARY
2006-09-26 10:42:55,669 [5628] DEBUG - FTPCommandSent:---> PASV
2006-09-26 10:42:55,669 [5628] DEBUG - FTPReplyReceived:227 Entering Passive Mode (10,216,8,151,151,148)
2006-09-26 10:42:55,669 [5628] DEBUG - FTPCommandSent:---> RETR "TEST 00029_02.xml"
2006-09-26 10:42:55,685 [5628] DEBUG - FTPReplyReceived:550 Failed to open file.
2006-09-26 10:42:55,685 [5628] ERROR - Method:FileUtils.GetFileFromDFD|Error:Failed to open file. (code=550)
0 votes
by (162k points)
That logging is fine. edtFTPnet is sending filenames with spaces as you can see (e.g. RETR see m00018_02.xml) so you don't need to put in quotes.

The issue here is why the server is not finding the file "see m00018_02.xml".

Are you in the correct directory on the server? Can you retrieve this file with command line FTP frpm the same server directory?
0 votes
by (240 points)
The system is in the correct folder to download the files as it manages to retrieve files without spaces in their names without error. The list of files to retrieve is being generated via a dir command within the FTP client and the application is designed to retrieve the files from the root FTP folder, so no directory traversal is being carried out.

Using the DOS FTP client built into Windows XP I am able to download the files from the FTP server as long as I wrap the filename in quotes when it has spaces in it, hence trying that within the code to see if it made a difference.

To get around the problem we have altered the system producing the files at the moment to remove any spaces from the filenames, however it would still be good to understand why the client is unable to retrive files when spaces exist.
0 votes
by (162k points)
The FTP client should be producing exactly the same command sent to the server as a command line client, i.e. what you see in the debug output from one should match the other. If this is the case they should both work or neither.

RETR abc efg hij.txt

should be what is sent to the server in each case. (quotes needed in the command line client to get this).

Can you post up a comparison of trying to retrieve exactly the same file by each? All we need is the couple of lines from the debug of edtFTPnet and ftp.exe.

thanks

Categories

...