I'm using webClient.DownloadFile() to download a file can I set a timeout for this so that it won't take so long if it can't access the file?
I'm using webClient.DownloadFile() to download a file can I set a timeout for this so that it won't take so long if it can't access the file?
Try WebClient.DownloadFileAsync(). You can call CancelAsync() by timer with your own timeout.
A lot of people make use of using(...) for the WebClient. Yes, WebClient implements IDisposable but this can cause socket exhaustion if you do it in bulk: https://www.aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/