Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows desktop devices.
3,003 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to get the size of the folder. I tried the following ways, both of them gives the size as 0 or null
IDictionary<string,object> property = await storageFolder.Properties.RetrievePropertiesAsync((new List<string>() { "System.Size"}));
IStorageItem selectedStorageItem = await StorageFolder.GetFolderFromPathAsync(selectedItem.ItemPath);
BasicProperties properties = await selectedStorageItem.GetBasicPropertiesAsync();
Hello,
Welcome to Microsoft Q&A!
The folder itself doesn't seem to have a size, the total size of folder is the sum of the sizes of the files inside the folder. So if you want to get the size of folder, it's better to calculate it by iterating on all files in the folder. For example:
var folders = folder.CreateFileQuery(CommonFileQuery.OrderByName);
var fileSizeTasks = (await folders.GetFilesAsync()).Select(async file => (await file.GetBasicPropertiesAsync()).Size);
var sizes = await Task.WhenAll(fileSizeTasks);
var folderSize = sizes.Sum(singleSize => (long)singleSize);