+1 vote
by (220 points)
edited

Hi,

I am calling the Delete method on Rebex.Net.Ftp and am getting an error message of "Could not find source path ('File Name.txt').". It works without a problem if there is no space in the file name. I have tried quoting the file name in double/single quotes and prefixing the name with a slash (/) but none of this helps.

How can I use Rebex FTP to delete a file that contains a space? I have searched across the forums for someone facing the same issue but couldn't find an answer. I also had the same problem when using FileExists, but in that case I quoted the file name with double quotes and it started working. However the Delete method doesn't seem to obey the same rules.

Any help would be greatly appreciated.

Thanks James

2 Answers

0 votes
by (58.9k points)
edited
 
Best answer

UPDATE

This turned out to be a problem only with certain ProFTPD server (namely versions 1.3.2x and older which require the filename with spaces to be quoted when issuing the MLST command.) However, in newer versions of ProFTPd (1.3.3 and newer) the quoting workaround cannot be applied anymore.

We have improved the MLST quoting workaround to handle both scenarios based on the ProFTPD server version. The improved workaround is available as part of version 2014R3 version of Rebex FTP/SSL.


Hello, I have tried this piece of code (it creates and deletes a file which has whitespace in its name):

Ftp ftp = new Ftp();
ftp.Connect("server", port);
ftp.Login("username", "password");

ftp.PutFile(new MemoryStream(), "File Name.txt");
ftp.Delete("File Name.txt", TraversalMode.MatchFilesShallow);

And it works fine with Rebex FTP (2012R3). I have tested it against following FTP servers:

  • Gene6
  • FileZilla
  • GlobalScape
  • MS IIS 6.0 FTP
  • WU-FTPD
  • Titan FTP

If it does not work with your FTP server, could you please create a communication log as described in this article and either post it here or send it to support@rebex.net?

In such case, would it be possible to try whether a third party FTP client (e.g. FileZilla) is able to delete the file or not, and if it is, please create log from FileZilla client and send it to us.

+1 vote
by (220 points)
edited

Thanks for the reply, changing the traversal mode from NonRecursive to MatchFilesShallow has solved the problem! Much appreciated. Is there a valid reason why NonRecursive wouldn't work with file names containing white space?

by (58.9k points)
edited

Thank you for your feedback.

Well, TraversalMode.NonRecursive should make no difference. For me it is also working fine. Could you please create two logs using my code above - one with NonRecursive mode and another one with MatchFilesShallow mode?

We would be able to look into this issue then.

by (58.9k points)
edited

For other users - from the logs we have received (thanks, DrBrain!) we have found, that ProFTPD server needs the filenames being quoted when issuing MLST command. The fix will be released as part of 2013R1. Hotfix is available on demand.

by (58.9k points)
edited

2013R1 version which fixes the issue has been released today. See complete list of changes in Rebex FTP/SSL.

by (58.9k points)
edited

Newer version of ProFTPD server behave differently and have been refusing our quoting workaround.

In release 2014R3, we have improved the workaround to be applied only for the specific ProFTPD server version which need it. See more details.

...