Beispiel #1
0
        public async Task CalculateSize()
        {
            try
            {
                if (SizeIsCalculated)
                {
                    return;
                }

                string        path   = TheApp.PackageDataFolder;
                StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(path);//PackageRootFolder.ToLower().Replace("c:\\data\\","u:\\"));

                List <IStorageItem> contents = await FileOperations.GetContents(folder);

                List <StorageFile> files = (from IStorageItem s in contents
                                            where s is StorageFile
                                            select(StorageFile) s).ToList();

                double sizeBytes = await FileOperations.GetSizeOfFiles(files);

                AppDataSize      = FileOperations.GetFileSizeString(sizeBytes);
                SizeIsCalculated = true;
                NotifyChange();
            }
            catch
            {
                AppDataSize = "Unknown";
            }
        }
        private async void LoadBackupSize(Backup item)
        {
            StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(System.IO.Path.Combine(App.BackupDestination, item.Name));

            StorageFile dataFile = (StorageFile)await folder.GetItemAsync("data.zip");

            BackupSizeText.Text = FileOperations.GetFileSizeString((await dataFile.GetBasicPropertiesAsync()).Size);
        }
        private async void LoadBackupSize(Backup item)
        {
            try
            {
                StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(System.IO.Path.Combine(App.BackupDestination, item.Name));

                StorageFile dataFile = (StorageFile)await folder.GetItemAsync("data.zip");

                BackupSizeText.Text = FileOperations.GetFileSizeString((await dataFile.GetBasicPropertiesAsync()).Size);
            }
            catch (Exception e1)
            {
                MessageDialog md = new MessageDialog("Item " + item.Name + " has a wrong name \n (get right name from metadata.json \n and apply to folder name!!!) ");
                md.Commands.Add(new UICommand("OK")
                {
                    Id = 1
                });
                //md.Commands.Add(new UICommand("No") { Id = 0 });
                md.DefaultCommandIndex = 1;
                //md.CancelCommandIndex = 0;

                var result = await md.ShowAsync();
            }
        }