[英]Windows IoT Raspberry Pi 3 C# GetDiskFreeSpace
I have a USB thumb-drive connected to my raspberry pi 3. I'd need to find out how to check for the available disk space to be printed on a textblock. 我的树莓派3连接了USB拇指驱动器。我需要了解如何检查要打印在文本块上的可用磁盘空间。 I couldn't find any example for UWP application. 我找不到UWP应用程序的任何示例。 What I found was GetDiskFreeSpaceEx function and Is there a method available for UWP apps to get available disk space Is there any example I could refer to? 我发现的是GetDiskFreeSpaceEx函数,并且UWP应用程序有可用的方法来获取可用磁盘空间吗?我可以参考任何示例吗? Thanks. 谢谢。
Updated: I have tried [Get available disk free space for a given path on Windows [duplicate]] .. Couldn't get it to work too.. 更新:我已经尝试过[在Windows上获取给定路径的可用磁盘可用空间[重复]] ..也无法使其正常工作。
You can use StorageFolder.Properties.RetrievePropertiesAsync() API to get the free space size of USB storage.I tested with the following pieces of code: 您可以使用StorageFolder.Properties.RetrievePropertiesAsync()API来获取USB存储设备的可用空间大小。我通过以下代码段进行了测试:
var removableDevices = KnownFolders.RemovableDevices;
var externalDevices = await removableDevices.GetFoldersAsync();
var usbDriver = externalDevices.FirstOrDefault();
var allProperties = usbDriver.Properties;
IEnumerable<string> propertiesToRetrieve = new List<string> { "System.FreeSpace" };
var storageIdProperties = await allProperties.RetrievePropertiesAsync(propertiesToRetrieve);
var freeSpaceSize = storageIdProperties["System.FreeSpace"].ToString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.