1 Replies - 420 Views - Last Post: 01 July 2012 - 09:39 AM Rate Topic: -----

#1 leeottaway  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-July 12

HttpWebRequest File Upload Not Working

Posted 01 July 2012 - 09:33 AM

Hi. I'm using the following code to upload a file to web space that I own and and has all access rights, however for some reason even though it looks like it should work and there are no errors the file is never created on the server. Does anyone have any ideas?
    Dim wr As System.Net.HttpWebRequest
    Dim ws As System.IO.Stream
    Dim sw As System.IO.StreamWriter
    Dim sr As System.IO.StreamReader
    Dim sFile As String = ""
    Dim sLine As String

        Try
            Dim su As New System.Uri(mypublicwebspace & sFile)

            wr = DirectCast(System.Net.WebRequest.Create(su), System.Net.HttpWebRequest)
            wr.Method = "PUT"
            wr.AllowWriteStreamBuffering = True
            wr.KeepAlive = True

            ws = wr.GetRequestStream()
            sw = New System.IO.StreamWriter(ws)
            sr = New System.IO.StreamReader(gsAppFolderPath & "\" & sFile)

            sLine = sr.ReadLine()

            While sLine IsNot Nothing
                sw.WriteLine(sLine)
                sLine = sr.ReadLine()
            End While

            sw.Close()
            sw.Dispose()
            sr.Close()
            sr.Dispose()
            ws.Close()
            ws.Dispose()

        Finally

        End Try

This post has been edited by modi123_1: 01 July 2012 - 09:39 AM
Reason for edit:: highlight your code and click the code button..


Is This A Good Question/Topic? 0
  • +

Replies To: HttpWebRequest File Upload Not Working

#2 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4928
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

Re: HttpWebRequest File Upload Not Working

Posted 01 July 2012 - 09:39 AM

:code:
Its not rocket science and its posted everywhere.

Attached Image

This post has been edited by tlhIn`toq: 01 July 2012 - 09:40 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1