Does WebClient.DownloadFileAsync overwrite the file if it already exists on disk?

Kashif picture Kashif · Jan 15, 2013 · Viewed 9.3k times · Source

I can't find any information on my question. Please excuse me if my search efforts have not been good enough to find the answer. I just want to avoid spinning my wheels.

Thanks!

Follow up: If it doesn't overwrite, how can I get it to (if possible)?

Answer

sa_ddam213 picture sa_ddam213 · Jan 15, 2013

A 30 second test confirms that it does overwrite

Test:

using (WebClient client = new WebClient())
{
    client.DownloadFileAsync(new Uri("http://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe"), @"C:\Test.exe");
}

Test.exe is overwitten if downlaoded again