title: Uploading file to FTP with VB.NET
body: <p>I'm getting errors when trying to upload a file to FTP Server with the next VB.NET code:</p>
  <pre><code>Dim miUri As String = &quot;ftp://ftp.mydomain.com/folder/file.jpg&quot;
  Dim miRequest As Net.FtpWebRequest = Net.WebRequest.Create(miUri)
  miRequest.Credentials = New Net.NetworkCredential(&quot;user&quot;, &quot;pass&quot;)
  miRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
  Try
      Dim bFile() As Byte = System.IO.File.ReadAllBytes(&quot;C:\carpeta\fichero.jpg&quot;)
      Dim miStream As System.IO.Stream = miRequest.GetRequestStream()
      miStream.Write(bFile, 0, bFile.Length)
      miStream.Close()
      miStream.Dispose()
  Catch ex As Exception
      Throw New Exception(ex.Message &amp; &quot;. El Archivo no pudo ser enviado.&quot;)
  End Try
  </code></pre>
  <blockquote>
  <p>ex.Message = &quot;Error on remote server: 227 Entering Passive Mode
  (x,x,x,x,21,183). .&quot; ex.InnerException.Message = System.Net.Sockets.SocketException = {&quot;A socket operation was attempted to an unreachable network x.x.x.x:5557&quot;}</p>
  </blockquote>
  <p>The line of code that throws the exception is:</p>
  <pre><code>Dim miStream As System.IO.Stream = miRequest.GetRequestStream()
  </code></pre>
  <p>POINTS:</p>
  <ul>
  <li><p>If I try to connect by FileZilla or other FTP Client, I can connect without problems.</p>
  </li>
  <li><p>If I disable the antivirus, I can connect without problems.</p>
  </li>
  <li><p>Before somebody says something related to the firewall...</p>
  </li>
  </ul>
  <p>IF THE ANTIVIRUS IS ON, AND I CONNECT BY FILEZILLA, I CAN CONNECT WITHOUT PROBLEMS.</p>
  <p>¿Where is the problem? ¿What I have to do in my code to get it run with the antivirus ON?
  If FileZilla can, I also have to be able...</p>
  <p>Thanks a lot for your replies.
  Regards,</p>