Beispiel #1
0
        private async Task UpdateCacheSizeAsync(bool resetInitialCacheSize, bool updateDetailedCacheSizes)
        {
            CacheSize = 0;
            if (resetInitialCacheSize)
            {
                InitialCacheSize = 0;
            }

            try
            {
                var cacheSize = NativeUtils.GetDirectorySize(FileUtils.GetTempFileName(string.Empty));
                CacheSize = cacheSize;
                if (resetInitialCacheSize)
                {
                    InitialCacheSize = cacheSize;
                }
                Percentage = InitialCacheSize > 0 ? Math.Round((double)(CacheSize * 100) / InitialCacheSize, 1) : 0.0D;
            }
            catch { }
            finally
            {
                if (updateDetailedCacheSizes)
                {
                    var files = await this.RetrieveCacheFilesAsync();

                    UpdateCacheTypes(files);
                }
            }
        }
        private async Task UpdateCacheSizeAsync()
        {
            CacheSize = 0;

            try
            {
                CacheSize = NativeUtils.GetDirectorySize(FileUtils.GetTempFileName(string.Empty));
            }
            catch { }
        }
Beispiel #3
0
        private async Task UpdateCacheSizeAsync()
        {
            CacheSize = 0;

            try
            {
                var folder = await ApplicationData.Current.LocalFolder.GetFolderAsync("temp");

                CacheSize = NativeUtils.GetDirectorySize(folder.Path);
            }
            catch { }
        }
Beispiel #4
0
        private void UpdateCacheSize(bool resetInitialCacheSize, bool updateDetailedCacheSizes)
        {
            CacheSize = 0;

            if (resetInitialCacheSize)
            {
                InitialCacheSize = 0;
            }

            try
            {
                var cacheSize = NativeUtils.GetDirectorySize(FileUtils.GetTempFileName(string.Empty));
                CacheSize = cacheSize;

                if (resetInitialCacheSize)
                {
                    InitialCacheSize = cacheSize;
                }

                Percentage = InitialCacheSize > 0 ? Math.Round((double)(CacheSize * 100) / InitialCacheSize, 1) : 0.0D;
            }
            catch { }
            finally
            {
                if (updateDetailedCacheSizes)
                {
                    var filter = Constants.MediaTypes;
                    var images = 0L;
                    var videos = 0L;

                    for (int i = 0; i < filter.Length; i++)
                    {
                        if (Constants.PhotoTypes.Contains(filter[i]))
                        {
                            images += NativeUtils.GetDirectorySize(FileUtils.GetTempFileName(string.Empty), "\\*" + filter[i]);
                        }
                        else
                        {
                            videos += NativeUtils.GetDirectorySize(FileUtils.GetTempFileName(string.Empty), "\\*" + filter[i]);
                        }
                    }

                    ImagesCacheSize     = images;
                    VideosCacheSize     = videos;
                    OtherFilesCacheSize = Math.Max(_cacheSize - images - videos, 0);
                }
            }
        }