/// <summary> /// 从列表中移除 /// </summary> /// <param name="item"></param> public void DeleteDeviceFormList(RemovableStatusModel item) { try { ListAll.RemoveAt(ListAll.FindIndex((u) => u.DeviceName == item.DeviceName)); } catch { } }
/// <summary> /// 插入设备时调用此方法。 /// </summary> /// <param name="usb"></param> public RemovableStatusModel Add() { var drivers = System.IO.DriveInfo.GetDrives(); foreach (var item in drivers) { if (item.DriveType == DriveType.Removable) { if (!ListAll.Exists(u => u.DeviceName == item.Name)) { var addModel = new RemovableStatusModel { DeviceInfo = item, DateTime = DateTime.Now, DeviceName = item.Name, IsConnectionToPc = true }; ListAll.Add(addModel); return(addModel); } } } return(null); }