I'm using the C# WebClient object and if I run the method 'DownloadFileAsync' and the remote file does not exist (AKA, I get an http 404 from the server) a WebException is not thrown. However, all of the synchronous calls do raise the exception.
The only way I can tell if the server return a 404 is by checking the length of the file I'm downloading to. If its length is zero then the remote file didn't exist. Is there a better way to catch when this condition happens? Checking the length of the downloaded file just seems hackish to me.
The only way I can tell if the server return a 404 is by checking the length of the file I'm downloading to. If its length is zero then the remote file didn't exist. Is there a better way to catch when this condition happens? Checking the length of the downloaded file just seems hackish to me.