Ok, I have a program that parses INI files (yes yes, I know, but I'm stuck with using them, not my own request), and it downloads external images (if the INI contains the path) to the program and cache's them.

Recently, I've run into a snag with the system. Most of the images use Imageshack for storage, but one of them has suddenly 404'd, and whenever I set it to the picturebox to the downloaded image, I get an out of memory error rather quickly (and the file itself is 1kb).

I guess I need to implement a checking system offline to find out if the image is actually an image or just a '404' text...but is there a way to not have to implement this clientside, and have it be checked when I download it?

Here's the downloading code:
vb.net Code:
  1. Public Function DownloadImageStream(ByVal ImageURL As String) As MemoryStream
  2.         Dim objImage As MemoryStream 'Create a MemoryStream
  3.         Dim objwebClient As WebClient 'Create a WebClient
  4.         Dim sURL As String = Trim(ImageURL) 'Remove any leading/ending spaces
  5.         Try
  6.             'Add the http:// if needed
  7.             If Not sURL.ToLower().StartsWith("http://") Then sURL = "http://" & sURL
  8.             'Initiate the new WebClient
  9.             objwebClient = New WebClient()
  10.             Dim url As Uri
  11.             url = New Uri(sURL)
  12.             'New MemoryStream from downloading the image
  13.             'from the specified url
  14.             objImage = New MemoryStream(objwebClient.DownloadData(url))
  15.             'Return the Image from the downloaded Stream
  16.             Return objImage
  17.         Catch ex As Exception
  18.             'custom error handling, don't worry about this.
  19.             Dim err As New default_ErrorDialog
  20.             err.ThrowError(ex.Message, ex.StackTrace, ex.InnerException.ToString)
  21.             Return Nothing
  22.         End Try
  23.     End Function