The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP] StorageFolder freespace RRS feed

  • Question

  • Hello,

    Is there a way to get the free space of a folder?

    I tried Properties.RetrievePropertiesAsync(new string[] { "System.FreeSpace" }), but eventually got null pointer exception.

    Thanks!

    Monday, October 3, 2016 6:31 AM

Answers


  • Hi Chunmiao,

    I have followed this article and used the code snippet below, but the RetrievePropertiesAsync method works fine for me.
    May I know what “Properties” and StorageFolder you are referring to, maybe there’s something to do with it. Or would you like to share your code.

    FolderPicker picker = new FolderPicker();
    picker.FileTypeFilter.Add(“*”);
    var folder = await picker.PickSingleFolderAsync();
    var basicProperties = await folder.GetBasicPropertiesAsync();
    var result = await basicProperties.RetrievePropertiesAsync(new string[]{“System.FreeSpace”});
    if(null != result)
    {
        string freeSpace = result[“System.FreeSpace”].ToString();
    }

    Best Regards,
    David

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    • Marked as answer by Chunmiao Wednesday, October 5, 2016 4:20 AM
    Tuesday, October 4, 2016 3:52 PM

All replies


  • Hi Chunmiao,

    I have followed this article and used the code snippet below, but the RetrievePropertiesAsync method works fine for me.
    May I know what “Properties” and StorageFolder you are referring to, maybe there’s something to do with it. Or would you like to share your code.

    FolderPicker picker = new FolderPicker();
    picker.FileTypeFilter.Add(“*”);
    var folder = await picker.PickSingleFolderAsync();
    var basicProperties = await folder.GetBasicPropertiesAsync();
    var result = await basicProperties.RetrievePropertiesAsync(new string[]{“System.FreeSpace”});
    if(null != result)
    {
        string freeSpace = result[“System.FreeSpace”].ToString();
    }

    Best Regards,
    David

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    • Marked as answer by Chunmiao Wednesday, October 5, 2016 4:20 AM
    Tuesday, October 4, 2016 3:52 PM
  • Thanks!

    Turns out cannot get the info for the KnownsFolder.

    Wednesday, October 5, 2016 4:21 AM