コード例 #1
0
ファイル: Item.cs プロジェクト: chcg/MediaDevices
        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);
        }
コード例 #2
0
ファイル: Item.cs プロジェクト: kiloecho2/MediaDevices
        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));
        }