HTTP Binary Get

  • Thread starter Thread starter Da Rabit
  • Start date Start date
D

Da Rabit

Hi All
I need to download a gif file from a url,t he file is binary written, so all
i need to do is get the file and save it from a URL. ( Used to use the old
http object in VB to do this) anyone know how to do this with the .NET
Framework ?
 
this is the base of how to do it (in C#)

using System;
using System.Net;
using System.Collections;
using System.IO;
using System.Web;
using System.Drawing;
using System.Text;

Bitmap rtn = null;
String contentType = "application/x-www-form-urlencoded";
object wreq = WebRequest.Create(url);
HttpWebRequest request = (HttpWebRequest) wreq;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT
5.0)";
response = request.GetResponse();
rtn =
(Bitmap)Image.FromStream(((HttpWebResponse)response).GetResponseStream());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top