public void Delete(PortableDevice mtpDevice, bool contentsAlso) { if (mtpDevice == null || !mtpDevice.IsConnected) { throw new ArgumentNullException(nameof(mtpDevice)); } foreach (var child in GetChildren(mtpDevice)) { if (contentsAlso) { ((PortableDeviceFolder)child).Delete(mtpDevice, true); } else { throw new IOException(); } } tag_inner_PROPVARIANT variant; StringToPropVariant(Id, out variant); IPortableDevicePropVariantCollection objectIds = new PortableDevicePropVariantCollection() as IPortableDevicePropVariantCollection; objectIds.Add(variant); mtpDevice.Content.Delete(0, objectIds, null); }
public void SyncPlaylists(iTunesLibrary library) { if (playlistFolder == null) { foobalator.Log.WriteLine("Playlists folder could not be found"); return; } foreach (var playlist in library.playlists) { try { DeviceObject deviceObject = playlistFolder.GetChildByName(playlist.name); if (deviceObject == null) { foobalator.Log.WriteLine(playlist.ToString()); var references = new PortableDevicePropVariantCollection(); foreach (var track in playlist.Tracks) { if (track.deviceObject == null) { continue; } //var item = Constants.ToPropVariant(track.deviceObject.id); //var item = new System.Runtime.InteropServices.VariantWrapper(track.deviceObject.id); //references.Add(item); } uint count = 0; references.GetCount(ref count); var values = new PortableDeviceValues(); values.SetStringValue(Constants.WPD_OBJECT_PARENT_ID, playlistFolder.id); values.SetStringValue(Constants.WPD_OBJECT_NAME, playlist.name); //values.SetStringValue(Constants.WPD_OBJECT_ORIGINAL_FILE_NAME, playlist.name); values.SetGuidValue(Constants.WPD_OBJECT_CONTENT_TYPE, Constants.WPD_CONTENT_TYPE_PLAYLIST); values.SetUnsignedIntegerValue(Constants.WPD_OBJECT_SIZE, count); //values.SetGuidValue(Constants.WPD_OBJECT_FORMAT, Constants.WPD_OBJECT_FORMAT_WPLPLAYLIST); //values.SetGuidValue(Constants.WPD_OBJECT_FORMAT, Constants.WPD_OBJECT_FORMAT_PROPERTIES_ONLY); //values.SetIPortableDevicePropVariantCollectionValue(Constants.WPD_OBJECT_REFERENCES, references); string playlistDeviceId = null; content.CreateObjectWithPropertiesOnly(values, ref playlistDeviceId); deviceObject = playlistFolder.GetChildByName(playlist.name, true); } playlist.deviceObject = deviceObject; } catch (Exception e) { foobalator.Log.Write(playlist.ToString(), e); } } }
public void DeleteFile(PortableDeviceFile file) { PortableDeviceClass.Content(out IPortableDeviceContent content); PortableDeviceApiLib.tag_inner_PROPVARIANT variant; StringToPropVariant(file.Id, out variant); var objectIds = new PortableDevicePropVariantCollection() as PortableDeviceApiLib.IPortableDevicePropVariantCollection; objectIds.Add(variant); content.Delete(0, objectIds, null); }
public void DeleteFolder(PortableDeviceFolder folder) { IPortableDeviceContent content; PortableDeviceClass.Content(out content); var variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT(); StringToPropVariant(folder.Id, out variant); var objectIds = new PortableDevicePropVariantCollection() as PortableDeviceApiLib.IPortableDevicePropVariantCollection; objectIds.Add(variant); content.Delete(1, objectIds, null); }
public void Delete(PortableDevice portableDevice) { if (portableDevice == null || !portableDevice.IsConnected) { throw new ArgumentNullException(nameof(portableDevice)); } var variant = new tag_inner_PROPVARIANT(); StringToPropVariant(Id, out variant); IPortableDevicePropVariantCollection objectIds = new PortableDevicePropVariantCollection() as IPortableDevicePropVariantCollection; objectIds.Add(variant); portableDevice.Content.Delete(0, objectIds, null); }
public virtual extern void SetIPortableDevicePropVariantCollectionValue([In] ref _tagpropertykey key, [In, MarshalAs(UnmanagedType.Interface)] PortableDevicePropVariantCollection pValue);