/// <summary>
        /// Download some data located at the specified url.
        /// </summary>
        public static byte[] DownloadData(Uri uri, WebProxy proxy)
        {
            // is it a local path?
            if (uri.IsFile)
            {
                try
                {
                    // just read the picture from the file system
                    return File.ReadAllBytes(uri.LocalPath);
                }
                catch (IOException)
                {
                    return null;
                }
                catch(SystemException exc)
                {
                    if(exc is UnauthorizedAccessException || exc is System.Security.SecurityException || exc is NotSupportedException)
                        return null;
                    throw;
                }
            }

            System.Net.WebClient webClient = new System.Net.WebClient();
            if (proxy != null)
            {
                if(proxy.Credentials != null)
                    webClient.Credentials = proxy.Credentials;
                if (proxy.Proxy != null)
                    webClient.Proxy = proxy.Proxy;
            }

            try
            {
                return webClient.DownloadData(uri);
            }
            catch (System.Net.WebException)
            {
                return null;
            }
        }
 public ImageProvisioningProvider(WebProxy proxy, HtmlImageInfo image)
 {
     this.proxy = proxy;
     this.imageInfo = image;
 }