string url = "URL";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Credentials = new NetworkCredential("test", "test", "test");
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
BinaryReader br = new BinaryReader(stream);
byte[] content = br.ReadBytes(500000);
br.Close();
string[] imagetype = url.Split('.');
Response.ContentType = "image/" + imagetype[imagetype.Length-1];
//Response.ContentType = "image/jpeg";
Response.BinaryWrite(content);
response.Close();
//string file_name = Server.MapPath(".") + "\\logo.jpg";
//FileStream fs = new FileStream(file_name, FileMode.Create);
//BinaryWriter bw = new BinaryWriter(fs);
//try
//{
// bw.Write(content);
//}
//finally
//{
// fs.Close();
// bw.Close();
//}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment