How to send arbitrary FTP commands in C#

I don’t think it can be done with FtpWebRequest… The only way to specify a FTP command is through the Method property, and the documentation states :

Note that the strings defined in the WebRequestMethods.Ftp class are the only supported options for the Method property. Setting the Method property to any other value will result in an ArgumentException exception.

SITE and SYST are not among the predefined options, so I guess you’re stuck…

Don’t waste time to try the WebClient class, it will give you even less flexibility than FtpWebRequest.

However, there are plenty of third-party FTP implementation, open source or commercial, and I’m pretty sure some of them can handle custom commands…

Leave a Comment