c# - How to get available space on Storage Device -
i'm working on windows store app (windows 8.1, using vs2012), , i'm having trouble retrieving available/used space specific storage folder, retrieved storage device. clear, app meant run on desktop, , exchange files usb devices connected through storage device api.
this have until now:
storagefolder folder = windows.devices.portable.storagedevice.fromid(phoneid); uint64[] info = new uint64[] {}; var properties = await folder.properties.retrievepropertiesasync( new string[] { "system.freespace", "system.capacity" }); if (properties.containskey("system.freespace") && properties.containskey("system.freespace")) { info = new uint64[] { (uint64) properties["system.freespace"], (uint64) properties["system.capacity"] }; } return info;
but no success, 'info' empty array. ideas?
i've found out doing wrong. storagefolder object representing phone connected desktop. if 1 goes through explorer , access phone folder, see 'inner folders', actual storage folders phone (eg. internal storage, sd card, etc).
the correct way phones access subfolders (ie. each internal storage). code i'm using now:
storagefolder folder = windows.devices.portable.storagedevice.fromid(phoneid); var data = new list<tuple<string, uint64[]>> { }; ireadonlylist<storagefolder> subfolders = await folder.getfoldersasync(); foreach (storagefolder subfolder in subfolders) { var props = await subfolder.properties.retrievepropertiesasync( new string[] { "system.freespace", "system.capacity" }); if (props.containskey("system.freespace") && props.containskey("system.capacity")) { data.add(tuple.create( subfolder.name, new uint64[] { (uint64) props["system.freespace"], (uint64) props["system.capacity"] })); } } return data;
Comments
Post a Comment