title: The remote server returned an error: (530) (Not logged in)
body: <p>I have changed the credentials etc at the bottom of course for security reasons, but could anyone offer any suggestions as to why this isn't working?</p>
  
  <p>I have used these credentials on FileZilla with no problems.</p>
  
  <p>Code:</p>
  
  <pre><code>Imports System.Net
  Imports System.IO
  
  Public Class Form1
  
  Private Sub FtpUploadFile(ByVal filetoupload As String, ByVal ftpuri As String, ByVal ftpusername As String, ByVal ftppassword As String)
      ' Create a web request that will be used to talk with the server and set the request method to upload a file by ftp.
      Dim ftpRequest As FtpWebRequest = CType(WebRequest.Create(ftpuri), FtpWebRequest)
  
      Try
          ftpRequest.Method = WebRequestMethods.Ftp.UploadFile
  
          ' Confirm the Network credentials based on the user name and password passed in.
          ftpRequest.Credentials = New NetworkCredential(ftpusername, ftppassword)
  
          ' Read into a Byte array the contents of the file to be uploaded 
          Dim bytes() As Byte = System.IO.File.ReadAllBytes(filetoupload)
  
          ' Transfer the byte array contents into the request stream, write and then close when done.
          ftpRequest.ContentLength = bytes.Length
          Using UploadStream As Stream = ftpRequest.GetRequestStream()
              UploadStream.Write(bytes, 0, bytes.Length)
              UploadStream.Close()
          End Using
      Catch ex As Exception
          MessageBox.Show(ex.Message)
          Exit Sub
      End Try
  
      MessageBox.Show("Process Complete")
  End Sub
  
  Private Sub Upload_Click(sender As Object, e As EventArgs) Handles Upload.Click
      FtpUploadFile("D:\Directory\Filename.csv", "ftp://www.****.com/test.csv", "****@*****.com", "*********")
  End Sub
  End Class
  </code></pre>
  
  <p>as requested I have tried to use WebClient see below code
          Try</p>
  
  <pre><code>    Dim up As New WebClient
          up.Credentials = New NetworkCredential("username", "password")
      up.UploadFile("ftp://www.domain.com/test.csv", "D:\test\test.csv")
          MsgBox("Done")
          up.Dispose()
  
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  End Sub
  </code></pre>
  
  <p>the results are the same;
  The remote server returned an error: (530) (Not logged in)</p>