The underlying connection was closed. The server committed a protocol violation

Implicit FTPS is not supported by the FtpWebRequest class (see here).

When EnableSsl is set to true, it actually triggers an AUTH TLS command to the server, asking to start an Explicit FTPS session.

In your case, you have to configure Filezilla Server to use Explicit FTPS. The procedure is documented on Filezilla Wiki


I've encountered the same problem but for uploading a file, on ftpWriter.Close(). Also, I was unable to do a GetRequestStream after a successful PrinWorkingDirectory for example.

The problem seems to be a "Expect: 100-continue" in the post - while I didn't quite checked this, the problem is somewhere there.

I've tried every solution found on the internet : changing the KeepAlive to true, adding to the App.Config file

<system.net>
    <settings>
        <servicePointManager expect100Continue="false"/>
        <httpWebRequest useUnsafeHeaderParsing="true"/>
    </settings>
</system.net>

Nothing really worked.

I've spend a lot of time and trying different other third party libraries (idea I didn't like too much), until finally I came on a code that used the same classes and method but worked !! After analyzing the code, I've finally figured out : the code targeted .NET Framework 2.0 while my code was targeting .NET Framework 4.5. I seems that Microsoft did a little bug while passing from Framework 3.5 to Framework 4.

As it's not a solution to convert your new projects to target an old framework, you can create a dll for the FTP operations, pointing to the 3.5 .NET Framework, or, you can use third party libraries.

I'm maybe a little bit late, but it will probably help other frustrated developers on this matter, in the future.