HttpWebRequest,WebClient no matter what
hi,
no matter what i'm doing trying to get a image file from the web, (any image - from any site)
i'm getting those errors one after the other:
Invalid or unsupported code page type
Unable to create a transport connection
and then after a few long seconds, time out.
what, what can i do to download a image from the web, i've written programs before in c++ and i had no trouble there .. i'm missing somthing ..
:confused: :confused:
[486 byte] By [
HushPuppy] at [2007-11-18 19:11:11]

# 2 Re: HttpWebRequest,WebClient no matter what
Hi,
here is my code, I took it from the web some where, anyhow when i reach the wr.GetResponse() function, i'm getting the errors ( as in the pictuer i'm sending you ).
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("http://maps.weather.com/web/radar/us_orl_ultraradar_large_usen.jpg");
HttpWebResponse ws = (HttpWebResponse)wr.GetResponse();
Stream str = ws.GetResponseStream();
byte[] inBuf = new byte[100000];
int bytesToRead = (int) inBuf.Length;
the 2nd code is just a simple webclient util, and i'm getting the same errors.
thanks for you help..
:D
# 3 Re: HttpWebRequest,WebClient no matter what
Ok, I think you have to set the correct contenttype.
wr.ContentType = "Image/jpeg";
Try it and share a look at the result.
# 4 Re: HttpWebRequest,WebClient no matter what
Nope, did'nt work, :(
what is the error, code page.. i can't find any info about it ..
# 5 Re: HttpWebRequest,WebClient no matter what
Here is a example from the msdn-library. It should work, but I didn't try it.
string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + fileName;
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" ......\n\n", fileName, myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource,fileName);
Console.WriteLine("Successfully Downloaded File \"{0}\" from \"{1}\"", fileName, myStringWebResource);
Console.WriteLine("\nDownloaded file saved in the following file system folder:\n\t" + Application.StartupPath);