Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
5
Answers
download image from url
bita hekmat
9y
428
1
Reply
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
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
How to give css on images and datalist control in asp.net
exporting formview data to pdf