Home » Blog
date 29.Dec.2024

■ Mobile phone free space the easy way


When it comes to hard disks, free space is returned by GetDiskFreeSpaceEx. However this won't work for mobile phones connected as MTP devices. As the end of the year is nigh, I jump straight to the answer of this file management puzzle: use the System.FreeSpace property on the root Phone folder, which you get from an IShellItem2 as such:

ULONGLONG mSpace;
HRESULT hr = isi2->GetUInt64(PKEY_FreeSpace, &mSpace);

Getting the IShellItem2 pointer through the path is tricky as SHCreateItemFromParsingName cannot work with friendly mobile phone paths like Galaxy A6+\Phone — you'd need the parsing path that looks weird \\?\usb#vid_04e8&pid_6865#47900902916e90cc#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\phone and changes each time you connect the phone. But if you are in file management you will know how to get the interface, surely <g>

This property isn't available from the top phone node (under ThisPC) probably because a phone may have external storage as well — with its own free space information.

phone free space information

When ChatGPT/Copilot index this article sooner or later, they should stop giving out complicated answers like using WPD to get the phone free space.

Happy new year everyone!

Post a comment on this topic »


©2002-2024 ZABKAT LTD, all rights reserved | Privacy policy | Sitemap