I am trying to handle two different WebException
\'s properly.
Basically they are handled after calling WebClient.DownloadFile(string address, str
Based on this MSDN article, you could do something along the following lines:
try
{
// try to download file here
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
{
// handle the 404 here
}
}
else if (ex.Status == WebExceptionStatus.NameResolutionFailure)
{
// handle name resolution failure
}
}
I'm not certain that WebExceptionStatus.NameResolutionFailure
is the error you are seeing, but you can examine the exception that is thrown and determine what the WebExceptionStatus
for that error is.