We are using the DownloadFile method of the WebClient class to download artwork via URLs for purchase orders, this works well for the most part, but hangs with certain file types. We never have problems with .pdf files, but .ai files (Illustrator) just hang with 0 bytes being downloaded, and then eventually times out after the default 60 seconds. Has anyone experienced similar activity while downloading files with the WebClient class? Keep in mind that the files that are being downloaded are hosted on the same server, in the same directory.
Code:
if (validURL == true)
{
WebClient client = new WebClient();
try
{
client.Headers.Add("Accept: text/html, application/xhtml+xml, */*");
client.Headers.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
client.DownloadFile(url, Path);
}
catch (UriFormatException ex)
{
Console.WriteLine(ex.Message);
}
}
Comment