public void Delete(bool recursive = false) { var objectIdCollection = (IPortableDevicePropVariantCollection) new PortableDevicePropVariantCollection(); var propVariantValue = PropVariantFacade.StringToPropVariant(this.Id); objectIdCollection.Add(ref propVariantValue.Value); IPortableDevicePropVariantCollection results = (IPortableDevicePropVariantCollection) new PortableDevicePropVariantCollection(); // TODO: get the results back and handle failures correctly this.device.deviceContent.Delete(recursive ? PORTABLE_DEVICE_DELETE_WITH_RECURSION : PORTABLE_DEVICE_DELETE_NO_RECURSION, objectIdCollection, ref results); ComTrace.WriteObject(objectIdCollection); }
public static Item GetFromPersistentUniqueId(MediaDevice device, string persistentUniqueId) { // fill collection with id to request var collection = (IPortableDevicePropVariantCollection) new PortableDevicePropVariantCollection(); using (var propVariantPUID = PropVariantFacade.StringToPropVariant(persistentUniqueId)) { collection.Add(ref propVariantPUID.Value); } // request id collection device.deviceContent.GetObjectIDsFromPersistentUniqueIDs(collection, out IPortableDevicePropVariantCollection results); string mediaObjectId = results.ToStrings().FirstOrDefault(); // return result item return(mediaObjectId == null ? null : Item.Create(device, mediaObjectId)); }