Hi guys,
I'm stuck with uploading obtaining a Stream. I'm putting the file with Filestream and it works great when files are smaller than 1gb.
I tried changing buffer size ... but no luck. If you could give me an advice, that would be great.
The crucial code is here. I did leave behind other parts of the code that are not essential and it would just make this part of the code harder to read.
Code:Dim wr As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest) ' NON LATIN char - > "multipart/form-data; charset=UTF-8; boundary=" + boundary; wr.ContentType = Convert.ToString("multipart/form-data; boundary=") & boundary wr.Method = "POST" wr.KeepAlive = True wr.Credentials = System.Net.CredentialCache.DefaultCredentials Dim rs As Stream = wr.GetRequestStream() Dim FS As New FileStream(File_Path, FileMode.Open, FileAccess.Read) Dim buffer As Byte() = New Byte(1024) {} Dim bytesRead As Integer = 0 Dim count As Integer = 0 While (InlineAssignHelper(bytesRead, FS.Read(buffer, 0, buffer.Length))) <> 0 rs.Write(buffer, 0, bytesRead) count += bytesRead Worker.ReportProgress(11, count) End While FS.Close()
Cheers!




Reply With Quote