Link to home
Start Free TrialLog in
Avatar of Shezad Ahmed
Shezad AhmedFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Uplolad file via System.Net.HttpWebRequest

I am trying to upload a file using HttpWebRequest.

The file does not seem to get uploaded.

I don't get any errors.

  Try


            Dim FTPaddress As String = "https://<server>/test/Khaosrs.exe/soap/IKosWeb/" + FileInfo.Name

            Dim request As System.Net.HttpWebRequest = DirectCast(System.Net.WebRequest.Create(FTPaddress), System.Net.HttpWebRequest)
            request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

            Dim file() As Byte = System.IO.File.ReadAllBytes(Filelocation)

            Dim strz As System.IO.Stream = request.GetRequestStream()
            strz.Write(file, 0, file.Length)
            strz.Close()
            strz.Dispose()

        Catch ex As Exception
            WritetoEventViewer("CPS - SL Update - UploadFiletoKhaosFTPsite() - " + ex.Message, True)
        End Try
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial