Keep it Simple

// practice, the distance between dream and achievement

Tag: WebClient

Utilities – Download images from a URL in C#

You may use the following method to retrieve the image from a specific URL on the web. The below C# function takes an image url, download the image from the url as a stream.

Continue reading

Utilities – Download an image with the appropriate extension using WebClient

I had to retrieve and save an image from the external websites to my local folder. While it can look like a simple task at the first glance, it can be complicated when you try to find the filename & extension using the URL.


though this is an Image, you would not be able to find the filename or extension by using the URL, so I had to come up with this.

Continue reading

Utilities – WebClient Timeout

The issue occurs when the time for generating the whole response of a WebClient request is longer than the default timeout (2 minutes) . So the solution is to increase this timeout value.

The WebClient class doesn’t have such property or method, so you have 2 possibilities:

  1. Use HttpWebRequest instead of WebClient and set its timeout by ReadWriteTimeout property. Of course the usage of this class is more complex than WebClient one but it gives you more flexibility.
  2. Make a derived class (wrapper) , which will set the timeout property of the base class of the WebClient.

Continue reading

© 2018 Keep it Simple

Theme by Anders NorenUp ↑