private Image DownloadImage(string pURL)
{
Console.WriteLine("Trying to get image : " + pURL);
Image _tmpImage = null;
try
{
System.Net.HttpWebRequest _HttpWebRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(pURL);
_HttpWebRequest.AllowWriteStreamBuffering = true;
_HttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";
_HttpWebRequest.Referer = "http://www.google.com/";
_HttpWebRequest.Timeout = 20000;
System.Net.WebResponse _WebResponse = _HttpWebRequest.GetResponse();
System.IO.Stream _WebStream = _WebResponse.GetResponseStream();
_tmpImage = Image.FromStream(_WebStream);
_WebResponse.Close();
_WebResponse.Close();
}
catch (Exception _Exception)
{
Console.WriteLine("Exception caught in process: {0}", _Exception.ToString());
return(null);
}
return(_tmpImage);
}