我正在使用MediaDevices
NuGet包来识别连接到计算机的所有媒体设备。我不确定如何获得MediaStorageInfo
,例如它可容纳多少空间或可用空间。
我的代码片段:
var mediadevices = mediadevice.GetDevices();
MediaStorageInfo info = new MediaStorageInfo();
foreach (var device in mediadevices)
{
ulong cap = info.Capacity
ulong freespace = info.FreespaceInObjects;
}
手册建议:
var devicess = MediaDevice.GetDevices();
using (var device = devicess.First(d => d.FriendlyName == "My Cell Phone"))
{
device.Connect();
// get list of available storages (SD-Card, Internal Flash, ...)
var objects = device.FunctionalObjects(FunctionalCategory.Storage);
MediaStorageInfo infoss = GetStorageInfo(objects.First());
ulong size = infoss.FreeSpaceInBytes;
device.Disconnect();
}
GetStorageInfo
似乎丢失,因为错误声明无法解决且当前联系中不存在。我不知道如何将MediaDevice
传递给{ {1}}。任何建议都有帮助。谢谢!
答案 0 :(得分:0)
只需更改:
string[]
到
GetStorageInfo(objects.First());
它看起来应该像这样:
device.GetStorageInfo(objects.First())