0

我正在使用MediaDevicesNuGet 包来识别连接到计算机的所有媒体设备。我不确定我如何获得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,因为错误指出无法解决并且当前联系人中不存在。我不确定如何将我的传递MediaDeviceMediaStorageInfo. 任何建议都有帮助。谢谢!

4

1 回答 1

0

只是改变:

GetStorageInfo(objects.First());

device.GetStorageInfo(objects.First())

它应该看起来像这样:

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 = device.GetStorageInfo(objects.First());
    ulong size = infoss.FreeSpaceInBytes;

   device.Disconnect();
}
于 2020-07-06T18:36:36.367 回答