I trying an execute a next code:

  using (var client = new Ftp()) {
    client.Connect("Server");
    client.Login("UserName", "Password");
    var size1 = client.GetFileLength(@"folder/file");
    var size2 = client.GetFileLength(@"folder\file");
  }//using

First, size1, is returned successfully, and second size2 is failed (on some servers) with FtpExceptionStatus.ProtocolError, "Requested action not taken. File doesnot exist (550).".

But, client.GetFile() with a second path is succeed. Do you can to format a path into a canonical form within a Ftp class?

asked 29 Jul '10, 13:15

_FRED_'s gravatar image

_FRED_
907
accept rate: 0%


Problem is that there is no "canonical form" of path in FTP protocol specification. Some FTP servers use only "/", some use only "\". Some allow both of them. And some may use a completely different directory separators.

The safest way is to split directory change and GetFileLength into two separate call.

using (var client = new Ftp()) {
    client.Connect("Server");
    client.Login("UserName", "Password");
    client.ChangeDirectory("folder");
    var size1 = client.GetFileLength("file");
  }//using

UPDATE::

Answer to "why GetFileLength is failed and GetFile no?"

The GetFileLength internally issues the SIZE filename command. The GetFile issues the RETR filename" command. It might be possible that this specific FTP server does support paths with '\' for RETR and doesn't support it for SIZE command.

It looks quite strange. Would it be possible to create a communication log from Rebex component (as described at rebex.net/kb/logging.aspx) and from FileZilla and either update your question or send it to support@rebex.net for analysis?

link

answered 29 Jul '10, 14:32

Martin%20Vobr's gravatar image

Martin Vobr ♦♦
335310
accept rate: 37%

edited 29 Jul '10, 16:15

Thanks! But, why GetFileLength is failed and GetFile no?

(29 Jul '10, 14:58) _FRED_

@FRED, I've updated my answer and discussed the GetFileLength and GetFile differences.

(29 Jul '10, 16:16) Martin Vobr ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×136

Asked: 29 Jul '10, 13:15

Seen: 475 times

Last updated: 29 Jul '10, 16:15