bita hekmat

bita hekmat

  • NA
  • 8
  • 3.5k

download image from url

May 28 2015 9:00 AM
hi everybody !
i want to download images from url (for Rss Reader) ,I used this method  for download image
 
//**
  public System.Drawing.Image DownloadImage(string _link)
{
System.Drawing.Image _tmpImage = null;


try
{
System.Net.HttpWebRequest _HttpWebRequest = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(_link);
_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 = System.Drawing.Image.FromStream(_WebStream);
_WebResponse.Close();

}
catch (Exception _Exception)
{
return null;
}


return _tmpImage;
}
 
 
 
//**
 
but  it  doesn't download from some links ,example:
 
 
 
http://yazdrasa.ir/documents/19536/11698058/IMG_7101.jpg?t=1431497996813

OR

http://www.khorasannews.com/NewsImage.aspx?id=1524477&filename=2002.jpg
 
 
 
 tanks for pay attention
 
 

Answers (5)