Q:

WebClient.DownloadFileTaskAsync and File.Exists

I'm using the following code to download a file and verify if the download succeeded:
        try
        {
            UpdateAvailable = false;
            Downloading = true;

            using (var webclient = new WebClient { CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) })
            {
                var file = Path.Combine(basePath, filename);
                await webclient.DownloadFileTaskAsync(updaterexe_fileurl, Path.Combine(basePath, updaterexe_filename));
                await webclient.DownloadFileTaskAsync(updatefileurl, file);
            }

            if (!File.Exists(filename))
            {
                Error = "Error downloading update. Please try again.";
                Log.Error("Error downloading update. Please try again (file does not exist).");
            }
            else
            {
                DownloadReady = true;
            }
        }
        catch (Exception ex)
        {
            Log.Error("Error downloading update: " + ex);
            Error = ex.Message;
        }
        finally
        {
            Downloading = false;
        }

This works in most cases. But I got multiple reports from end-users that sometimes they get the 'try again' error message.
How is this even possible? Clearly, WebClient didn't throw an exception, but it also failed to download the file (it did not exist on disk).
Is this a caching issue? Am I missing any other error handling?
If it's a disk caching issue, I thought about adding the following:
            int count = 0;
            while (count < 3 || !File.Exists(filename))
            {
                Thread.Sleep(1000);
                count++;
            }

But this feels very hacky.
Any ideas?

A:

You download to file, which is Path.Combine(basePath, filename) but you never check to see whether file exists, you check to see whether filename exists.
If basePath and the current working directory differ, the file "won't exist".

