ftp upload, corrupt file
<p>This is my code for upload a file to a FTP server:</p>

<pre><code>Dim _FileStream As System.IO.FileStream
Dim _Stream As System.IO.Stream

Dim _FileName As String = LocalPath + "/" + Name
Dim _FileInfo As New System.IO.FileInfo(_FileName)
Dim _FtpWebRequest As System.Net.FtpWebRequest

' Create FtpWebRequest object from the Uri provided
_FtpWebRequest = CType(WebRequest.Create("ftp://" + hostLocal + ":" + portLocal.ToString + "/" + Name), FtpWebRequest)

' Provide the WebPermission Credintials
_FtpWebRequest.Credentials = New System.Net.NetworkCredential(userNameLocal, passwordLocal)

' By default KeepAlive is true, where the control connection is not closed
' after a command is executed.
_FtpWebRequest.KeepAlive = False

' set timeout for 20 seconds
_FtpWebRequest.Timeout = 20000

' Specify the command to be executed.
_FtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

' Specify the data transfer type.
_FtpWebRequest.UseBinary = True

' Notify the server about the size of the uploaded file
_FtpWebRequest.ContentLength = _FileInfo.Length

' The buffer size is set to 32kb
Dim buffLength As Integer = 32768
Dim buff(buffLength - 1) As Byte
</code></pre>

<p>I use 32Kb buffer size because if I try to use 2Kb it works too slow</p>

<pre><code>' Opens a file stream (System.IO.FileStream) to read the file to be uploaded
_FileStream = _FileInfo.OpenRead()

' Stream to which the file to be upload is written
_Stream = _FtpWebRequest.GetRequestStream()


' Read from the file stream 32kb at a time
Dim contentLen As Integer = _FileStream.Read(buff, 0, buffLength)

Do While contentLen &lt;&gt; 0
    ' Write Content from the file stream to the FTP Upload Stream
    _Stream.Write(buff, 0, contentLen)
    contentLen = _FileStream.Read(buff, 0, buffLength)
Loop

' Close the file stream and the Request Stream
_FileStream.Close()
_FileStream.Dispose()
_Stream.Close()
_Stream.Dispose()
</code></pre>

<p>I have a problem with this function. If I try to upload a zip file to FTP server I receive a corrupt file.
Please help me. I use visual studio 2008 and .net framework 2.0</p>