Good day.
I'm using the WebClient
class in my C# application in order to download the same file every minute, and then the application performs a simple check to see if the file has been changed, and if it does do something with it.
Well since this file is downloaded every minute the WebClient
caching system is caching the file, and not downloading the file again, just simply getting it from the cache, and that gets in the way of checking if the file downloaded is new.
So i would like to know how can disable the caching system of the WebClient
class.
I've tried.
Client.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache);
I also tried headers.
WebClient.Headers.Add("Cache-Control", "no-cache");
Didn't work as well. So how can i disable the cache for good?
Thanks.
EDIT
I also tried the following CacheLevels
: NoCacheNoStore
, BypassCache
, Reload
. No effect, however if i reboot my computer the cache seems to be cleared, but i can't be rebooting the computer every time.