' Open a connection to the URL where the report is available. Dim webRequest As HttpWebRequest = Net.WebRequest.Create _(statusResponse.ReportRequestStatus.ReportDownloadUrl) Dim response = CType(webRequest.GetResponse, HttpWebResponse) Dim httpStream = response.GetResponseStream ' Open the destination file. Dim zipFileInfo = New FileInfo(zipFileName) If Not zipFileInfo.Directory.Exists Then zipFileInfo.Directory.Create() End If Dim fileStream = New FileStream(zipFileInfo.FullName, FileMode.Create) Dim ms = New MemoryStream Dim binaryWriter = New BinaryWriter(FileStream) Dim binWriter = New BinaryWriter(ms) Dim binaryReader = New BinaryReader(httpStream) Try ' Read the report, and then write it to the destination file. Dim bufferSize As Integer = 100000 While True ' Read the report data. Dim buffer() = binaryReader.ReadBytes(bufferSize) ' Write the report data to the destination file. binaryWriter.Write(buffer) binWriter.Write(buffer) Console.WriteLine(buffer.Length) ' If the end of the report is reached, break out of the ' loop. If (buffer.Length <> bufferSize) Then Exit While End If End While Finally ' Clean up. binaryWriter.Close() binaryReader.Close() fileStream.Close() httpStream.Close() End Try Dim reader As New StreamReader(ms, System.Text.Encoding.UTF8) Dim xmlString As String = reader.ReadToEnd() Console.WriteLine(xmlString) 'just using this to see what is in the string
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)