E
Enrico Pavesi
After that the following code give me two error (for file not present), i
always get timeout.
Any Hints?
Using SP3
Dim req As HttpWebRequest = CType(WebRequest.Create(WebPath + downloadUrl),
HttpWebRequest)
Dim resp As HttpWebResponse
req.Method = "GET"
Try
resp = CType(req.GetResponse(), HttpWebResponse)
' Retrieve response stream
Dim respStream As Stream = resp.GetResponseStream()
' Create local file
Dim wrtr As New FileStream(localFile, FileMode.Create)
' Allocate byte buffer to hold stream contents
Dim inData(4095) As Byte
' loop through response stream reading each data block
' and writing to the local file
Dim bytesRead As Integer = respStream.Read(inData, 0, inData.Length)
While bytesRead > 0
wrtr.Write(inData, 0, bytesRead)
bytesRead = respStream.Read(inData, 0, inData.Length)
End While
respStream.Close()
wrtr.Close()
Catch ex As Exception
req.Abort()
Throw ex
Finally
If (Not resp Is Nothing) Then
resp.Close()
End If
req = Nothing
End Try
always get timeout.
Any Hints?
Using SP3
Dim req As HttpWebRequest = CType(WebRequest.Create(WebPath + downloadUrl),
HttpWebRequest)
Dim resp As HttpWebResponse
req.Method = "GET"
Try
resp = CType(req.GetResponse(), HttpWebResponse)
' Retrieve response stream
Dim respStream As Stream = resp.GetResponseStream()
' Create local file
Dim wrtr As New FileStream(localFile, FileMode.Create)
' Allocate byte buffer to hold stream contents
Dim inData(4095) As Byte
' loop through response stream reading each data block
' and writing to the local file
Dim bytesRead As Integer = respStream.Read(inData, 0, inData.Length)
While bytesRead > 0
wrtr.Write(inData, 0, bytesRead)
bytesRead = respStream.Read(inData, 0, inData.Length)
End While
respStream.Close()
wrtr.Close()
Catch ex As Exception
req.Abort()
Throw ex
Finally
If (Not resp Is Nothing) Then
resp.Close()
End If
req = Nothing
End Try