Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# how-to-download-image-from-url

using (WebClient webClient = new WebClient()){
	byte[] dataArr = webClient.DownloadData("url.jpg");
	//save file to local
  	File.WriteAllBytes(@"path.png", dataArr);
}
Comment

c# download image from url

public static bool DownloadImage(string imageUrl, string filename, ImageFormat format)
{    
    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();

    return File.Exists(filename);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# string is all zeros 
Csharp :: 110771 
Csharp :: Filter list contents with predicate (Lambda) 
Csharp :: chaine de connexion sql server c# 
Csharp :: IOS app crashing on ios 15 unity 
Csharp :: move position smoth unity 
Csharp :: unity button hover 
Csharp :: c# read key without writing 
Csharp :: mock return exception c# 
Csharp :: c# picturebox zoom 
Csharp :: web socket background.js example 
Csharp :: return last row if all other condition fails in linq c# 
Csharp :: c# return error status code based on exception 
Csharp :: c# aspx return image 
Csharp :: C# console out restore 
Csharp :: auto paly a video control in mvc c# 
Csharp :: c# crud observablecollection -mvvm 
Csharp :: invalid length for a base-64 char array or string. frombase64string c# 
Csharp :: blender how to switch cameras 
Csharp :: c# list add and return 
Csharp :: how to display only date from datetime in mvc view 
Csharp :: spring jar debug level running 
Csharp :: kendo razor textbox 
Csharp :: short in c# 
Csharp :: WixSharp-FirewallException 
Csharp :: C# Printing Variables and Literals using WriteLine() and Write() 
Csharp :: unity raycast hit child object 
Csharp :: c# array accessor 
Csharp :: stringbuilder sb = new stringbuilder(reallylongstring); you need to identify whether a string stored in an object named stringtofind is within the stringbuilder sb object. 
Csharp :: partial mvc 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =