Hi, I'm trying to upload a file to my webserver. File is not showing on server.
Can anyone help me out here?
This is the code I'm using:
.net Code:
Private Sub btnSEND_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSEND.Click Dim clsRequest As System.Net.FtpWebRequest Try clsRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.blahblah.co.za/test.txt"), System.Net.FtpWebRequest) clsRequest.Credentials = New System.Net.NetworkCredential("MyUSERNAME", "MyPassword") clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile Catch ex As Exception MsgBox(ex.Message.ToString) End Try ' read in file... Dim bFile() As Byte = System.IO.File.ReadAllBytes(Application.StartupPath & "\test.txt") ' upload file... Dim clsStream As System.IO.Stream = _ clsRequest.GetRequestStream() Try clsStream.Write(bFile, 0, bFile.Length) clsStream.Close() clsStream.Dispose() Catch ex As Exception MsgBox(ex.Message.ToString) End Try MsgBox("done") End Sub


Reply With Quote
