2

I'm working on FTP client using .NET FtpWebRequest.

What I'm noticing that SOME servers instead of just file name - return full path to file like so:

-rw-rw-rw- 1 generic 235 Mar 22 11:21 fromDoder/DOD997ABCD.20170322112114159.1961812284.txt

Where I expect it to be:

-rw-rw-rw- 1 generic 235 Mar 22 11:21 DOD997ABCD.20170322112114159.1961812284.txt

Why does it happen? In my code I DO set directory in URL (to fromDoder) and on most FTP servers it would return only file names. I'm just trying to understand what's a difference and how should I parse it

katit
  • 17,375
  • 35
  • 128
  • 256
  • 1
    The format of response to `LIST` FTP command is not standardized in any way. Be glad that you get such a tiny difference only. It could be a way worse - Anyway, if you want more concrete answer, wee need to know what FTP server those are. Or even better a [complete log for both servers](http://stackoverflow.com/q/9664650/850848). – Martin Prikryl Mar 23 '17 at 07:56
  • If you can, I'd _highly_ recommend switching to using the [`MLSD`](https://tools.ietf.org/html/rfc3659#section-7) FTP command, which defines a standard format for listing file information on an FTP server. – Castaglia Mar 23 '17 at 15:30
  • II wish. Couple issues. We deal with some servers that don't support it. And, we use .NET CLR for FTP which doesn't support it. We migrate off the 3rd party components into using .NET native. It works great so far. Parsing various outputs will work for us. For some really weird cases(and usually those don't support MLSD :) ) - we just support RegEx in app settings – katit Mar 23 '17 at 15:32
  • @katit did you find a solution to this? – Nigel Fds Nov 16 '21 at 23:04
  • No solution, we just added options to handle different FTP server response structures – katit Dec 10 '21 at 20:27

0 Answers0