I want to get capacity of the disc in my Windows Phone 8.1 RT project.
I have learned that I need to use this function (p-invoking GetFileInformationByHandleEx) for this.
But I could not find any examples for use. Can someone help me by an example?
I tried following:
1.
private async Task<UInt64> GetCapacity(StorageFolder folder)
{
var retrivedProperties = await folder.Properties.RetrievePropertiesAsync(new string[] { "System.Capacity" });
return (UInt64)retrivedProperties["System.Capacity"];
}
2.
[DllImport("api-ms-win-core-file-l1-2-0.dll", CharSet = CharSet.Unicode, EntryPoint ="GetDiskFreeSpaceEx", SetLastError = true)]
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
out ulong lpFreeBytesAvailable,
out ulong lpTotalNumberOfBytes,
out ulong lpTotalNumberOfFreeBytes);
ulong GetDiskSize(string volumeName)
{
ulong avail;
ulong total;
ulong totalFree;
GetDiskFreeSpaceEx(volumeName, out avail, out total, out totalFree);
return total;
// return others as desired
}
I did not get result.