我正在使用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
给MediaStorageInfo
. 任何建议都有帮助。谢谢!