private static void ClearImpl(object param) { try { string[] files = Directory.GetFiles(HTTPCacheService.CacheFolder); for (int i = 0; i < files.Length; i++) { try { string fileName = Path.GetFileName(files[i]); HTTPCacheService.DeleteEntity(HTTPCacheService.GetUriFromFileName(fileName), true); } catch { } } } finally { HTTPCacheService.SaveLibrary(); HTTPCacheService.InClearThread = false; } }
private static void DeleteUnusedFiles() { HTTPCacheService.CheckSetup(); string[] files = Directory.GetFiles(HTTPCacheService.CacheFolder); for (int i = 0; i < files.Length; i++) { try { string fileName = Path.GetFileName(files[i]); Uri uriFromFileName = HTTPCacheService.GetUriFromFileName(fileName); Dictionary <Uri, HTTPCacheFileInfo> obj = HTTPCacheService.Library; lock (obj) { if (!HTTPCacheService.Library.ContainsKey(uriFromFileName)) { File.Delete(files[i]); } } } catch { } } }