I am successfully downloading files with below code. Since I want them to be downloaded on Application Startup I do not want to block anything -> async.
However I am facing the problem that even when the URI path is complete nonsense it will generate me an empty file, instead of raising the error like stated in msdn
Can anyone help me?
private void DownloadDocuments()
{
using (WebClient myWebClient = new WebClient())
{
try
{
Log("load1");
myWebClient.DownloadFileAsync(new Uri(documentsUri + documentActivation), documentspath + "\\" + documentActivation);
}
catch (WebException)
{
Log("Guide Activation Download failed.");
}
catch (InvalidOperationException)
{
Log("Guide Activation could not be saved.");
}
}
using (WebClient myWebClient = new WebClient())
{
try
{
Log("load2");
myWebClient.DownloadFileAsync(new Uri(documentsUri + documentFloating), documentspath + "\\" + documentFloating);
}
catch (WebException)
{
Log("Guide Floating Download failed.");
}
catch (InvalidOperationException)
{
Log("Guide Floating could not be saved.");
}
}
using (WebClient myWebClient = new WebClient())
{
try
{
Log("load3");
myWebClient.DownloadFileAsync(new Uri(documentsUri + documentSeat), documentspath + "\\" + documentSeat);
}
catch (WebException)
{
Log("Guide Seat Download failed.");
}
catch (InvalidOperationException)
{
Log("Guide Seat could not be saved.");
}
}
}