コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }