Posts Getting the Free Storage Space in WinRT
Post
Cancel

Getting the Free Storage Space in WinRT

I didnt find any documenation to this method other than the thread in StackOverflow: http://stackoverflow.com/questions/19510449/disk-space-in-winrt-using-c-sharp-in-windows-8

so im keeping it here so it wont get lost by the winds of time….

public static async Task<UInt64> GetFreeSpace(this IStorageItem sf)
{
    var properties = await sf.GetBasicPropertiesAsync();
    var filteredProperties = await properties.RetrievePropertiesAsync(new[] { "System.FreeSpace" });
    var freeSpace = filteredProperties["System.FreeSpace"];
    return (UInt64)freeSpace;
}

Sample use:

var freeSpace = await ApplicationData.Current.LocalFolder.GetFreeSpace();
Debug.WriteLine(freeSpace.GetSizeString());

Thank you  Filip Skakun

This post is licensed under CC BY 4.0 by Tamir Dresher.

Trending Tags