Hi,
Me too came across same situation, and bit of R&D leads me to the following solution.
On a simple form there is a FileUpload control (say FileUpload1) and a Button Control (say Button1). On Click event of button write following code
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f as bool = Upload(FileUpload1.FileBytes, FileUpload1.FileName, "abcftp", "abc@ftp", "ftp://ftp.someftp.com")
Response.Write(f = True, "Uploaded Successfully", "Unable to Upload")
End Sub
Upload() function does all the magic
Public Function Upload(FileByte() As Byte, FileName As String, ftpUserID As String, ftpPassword As String, ftpURL As String) As Boolean
Dim retValue As Boolean = False
Try
Dim ftpFullPath As String = ftpURL + "/" + FileName
Dim ftp As FtpWebRequest = FtpWebRequest.Create(New Uri(ftpFullPath))
ftp.Credentials = New NetworkCredential(ftpUserID, ftpPassword)
ftp.KeepAlive = True
ftp.UseBinary = True
ftp.Method = WebRequestMethods.Ftp.UploadFile
Dim ftpStream As Stream = ftp.GetRequestStream()
ftpStream.Write(FileByte, 0, FileByte.Length)
ftpStream.Close()
ftpStream.Dispose()
retValue = True
Catch ex As Exception
Throw ex
End Try
Return retValue
End Function
I hope this will help.
Thanks.