Exemple #1
0
        private void BeginCountCurrentCacheSize()
        {
            Task.Factory.StartNew(async() =>
            {
                IReadOnlyList <StorageFile> cacheFiles;
                try
                {
                    var storageFolder = await SF.GetFolderAsync(CacheDirectory);
                    cacheFiles        = await storageFolder.GetFilesAsync();
                }
                catch (Exception)
                {
                    return;
                }

                long cacheSizeInBytes = 0;

                foreach (var cacheFile in cacheFiles)
                {
                    var properties        = await cacheFile.GetBasicPropertiesAsync();
                    var fullCacheFilePath = cacheFile.Name;
                    try
                    {
                        cacheSizeInBytes += (long)properties.Size;
                        _lastAccessTimeDictionary.Add(fullCacheFilePath, properties.DateModified.DateTime.Milliseconds());
                    }
                    catch
                    {
                        ImageLog.Log("[error] can not get cache's file size: " + fullCacheFilePath);
                    }
                }
                CurrentCacheSizeInBytes += cacheSizeInBytes; // Updating current cache size
            });
        }