private void BeginCountCurrentCacheSize() { Task.Factory.StartNew(() => { // Pattern to match all innerFiles and innerDirectories inside absoluteDirPath var filesAndDirectoriesPattern = CacheDirectory + @"\*"; string[] cacheFileNames; try { cacheFileNames = ISF.GetFileNames(Path.Combine(CacheDirectory, filesAndDirectoriesPattern)); } catch { return; } long cacheSizeInBytes = 0; foreach (var cacheFileName in cacheFileNames) { var fullCacheFilePath = Path.Combine(CacheDirectory, cacheFileName); try { using (var file = ISF.OpenFile(fullCacheFilePath, FileMode.Open, FileAccess.Read)) { cacheSizeInBytes += file.Length; _lastAccessTimeDictionary.Add(fullCacheFilePath, DateTimeUtil.ConvertDateTimeToMillis(ISF.GetLastAccessTime(fullCacheFilePath).DateTime)); } } catch { JetImageLoader.Log("[error] can not get cache's file size: " + fullCacheFilePath); } } CurrentCacheSizeInBytes += cacheSizeInBytes; // Updating current cache size }); }