strURL = "http://www.websitename.com/xxx.pdf"
[begin snip]
Dim objStream As System.IO.Stream
Dim objReader As System.IO.StreamReader
Try
Dim objRequest As System.Net.HttpWebRequest =
System.Net.WebRequest.Create(strURL)
Dim objResponse As System.Net.WebResponse = objRequest.GetResponse
objStream = objResponse.GetResponseStream
objReader = New System.IO.StreamReader(objStream)
Return objReader.ReadToEnd
Catch ex As Exception
Return ""
Finally
objStream.Close()
objReader.Close()
End Try
[End snip]
What happens:
1. Using IE6, the file downloads fine, and opens as expected with
Adobe on my workstation (it's a good file on from the Website.)
1. The above VB.NET code executes. No execution errors.
2. The PDF file downloads, but is incomplete:
o The first part of the PDF file (ASCII text) matches the
original
o The last part of the PDF file (also ASCII text) matches the
original
3. The file size is about 60% of what it should be.
4. Adobe opens the file, if downloaded by IE
5. Adobe dies on an error (14) if downloaded with the code above.
We suspect this is related to a binary download (ASCII chars > 128).
Upper ASCII charters ARE downloaded, just not all of them?
Should I be using another VB.NET object/method? Microsoft's Website
shows ASP code, using the RESPONSE object.
Robert Keller
The StreamReader converts the bytes to chars using an decoder. You don't
want to do that. Use ObjStream.Read to read the bytes directly.
You might just use the System.Net.WebClient.DownloadFile method. It already
does this.
David
David,
"System.Net.WebClient.DownloadFile" worked the first time. Thanks a million
RK