title image


Smiley Re: Download von Binär-Dateien
Zwei Methoden, ohne StreamReader/BinaryReader



private void Form1_Load(object sender, System.EventArgs e)

{

HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create("http://spotlight.de/pic/icons/message_icon_1.gif");

webreq.Method = "GET";

webreq.KeepAlive = false;

WebResponse webresp = webreq.GetResponse();

Stream strm = webresp.GetResponseStream();



//image1(strm);

//image2(strm);



webresp.Close();

}



private void image1(Stream strm)

{

Image img = Image.FromStream(strm);

img.Save("C:\\image1.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

img.Dispose();

}



private void image2(Stream strm)

{

byte[] bytes = new byte[1024];

int bytesRead = 0;

FileStream fstrm = new FileStream("C:\\image2.gif", FileMode.Create, FileAccess.Write, FileShare.None);

while ((bytesRead = strm.Read(bytes, 0, bytes.Length)) > 0)

{

fstrm.Write(bytes, 0, bytesRead);

}

fstrm.Close();

}

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: