Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.
'This the core code from a dll class that works with a windows form. 'Get the length of the selected file Dim fi As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(filePath) Dim fileLength As Long = fi.Length 'Create the request Dim request As HttpWebRequest = _ DirectCast(HttpWebRequest.Create(address), HttpWebRequest) 'Configure request request.Credentials = New System.Net.NetworkCredential("UserName", "Password") request.Method = WebRequestMethods.Http.Put request.KeepAlive = True request.Timeout = -1 request.ContentLength = fileLength.ToString() 'This is required for our WebDav server request.SendChunked = True request.Headers.Add("Translate: f") request.AllowWriteStreamBuffering = True Dim s As IO.Stream = request.GetRequestStream() Dim fs As New IO.FileStream(filePath, IO.FileMode.Open, IO.FileAccess.Read) Dim byteTransferRate As Integer = 1024 Dim bytes(byteTransferRate - 1) As Byte Dim bytesRead As Integer = 0 Dim totalBytesRead As Long = 0 Do bytesRead = fs.Read(bytes, 0, bytes.Length) If bytesRead > 0 Then totalBytesRead += bytesRead 'Write to stream s.Write(bytes, 0, bytesRead) End If Loop While bytesRead > 0 s.Close() s.Dispose() s = Nothing fs.Close() fs.Dispose() fs = Nothing 'It basically hangs here for over 10 minutes and then produces the error. Dim response As HttpWebResponse = DirectCast(request.GetResponse(), _ HttpWebResponse)
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.