🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / C# RMOS / httpclient ile image downloand resim indirme httpwebclient

1-) C# RMOS - httpclient ile image downloand resim indirme

 

 using (WebClient client1 = new WebClient())

                    {

  client1.DownloadFileAsync(new Uri("urlPath"), @"depo\resimler\" + cafeModel.code + ".jpg");

or
  client1.
DownloadFile(new Uri("urlPath"), @"depo\resimler\" + cafeModel.code + ".jpg");

 

 

                    }

 

2-) İkinci Yol

 

  var request = WebRequest.Create(text);

  Image image = null;

  using (var response = request.GetResponse())

  using (var stream = response.GetResponseStream())

     {

      image = Bitmap.FromStream(stream);

   }

 

 3-) Üçüncü Yol

 

 public void SaveImage(string filename, ImageFormat format,string imageUrl)

        {

            WebClient client = new WebClient();

            Stream stream = client.OpenRead(imageUrl);

            Bitmap bitmap; bitmap = new Bitmap(stream);

 

            if (bitmap != null)

            {

                bitmap.Save(filename, format);

            }

 

            stream.Flush();

            stream.Close();

            client.Dispose();

        }

 

 KULLANIMI :

string resimUrl = "https://GOOGLE.com"+ resimSonUrl;                   SaveImage(@"resimler\2.jpg",ImageFormat.Jpeg,resimUrl);

 2022 Haziran 11 Cumartesi
 669