Beispiel #1
0
        /**
         * Delete a file.
         */
        public void DeleteFile(PortableDeviceFile file)
        {
            try
            {
                // make sure that we are not holding on to a file.
                DisconnectConnect();

                IPortableDeviceContent content = getContents();

                var variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();
                StringToPropVariant(file.Id, out variant);

                PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds =
                    new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                    as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
                objectIds.Add(variant);

                content.Delete(0, objectIds, null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw (ex);
            }
            Disconnect();
        }
Beispiel #2
0
        public bool DeleteContentFromDevice(string objectId)
        {
            bool bRet = false;

            PortableDeviceApiLib.IPortableDevicePropVariantCollection toDelete =
                new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
            PortableDeviceApiLib.IPortableDevicePropVariantCollection result =
                new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                as PortableDeviceApiLib.IPortableDevicePropVariantCollection;

            var pv = new PortableDeviceApiLib.tag_inner_PROPVARIANT();

            StringToPropVariant(objectId, out pv);

            toDelete.Add(ref pv);

            try
            {
                deviceContent.Delete((uint)DELETE_OBJECT_OPTIONS.NO_RECURSION, toDelete, ref result);
            }
            catch (Exception)
            {
                bRet = false;
            }

            return(bRet);
        }
        public void DeleteFile(PortableDeviceFile file)
        {
            var variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();
            IPortableDeviceContent content = null;

            try
            {
                this._device.Content(out content);

                StringToPropVariant(file.Id, out variant, 2);

                PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds =
                    new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                    as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
                objectIds.Add(variant);


                content.Delete(0, objectIds, null);
            }
            catch (Exception ex)
            {
                Logger.Basic.Error("Portable Device DeleteFile : " + ex.ToString(), ex);
            }
            finally {
                if (Marshal.IsComObject(variant))
                {
                    Marshal.ReleaseComObject(variant);
                }

                if (content != null && Marshal.IsComObject(content))
                {
                    Marshal.ReleaseComObject(content);
                }
            }
        }
Beispiel #4
0
        public void DeleteFile(PortableDeviceFile file)
        {
            IPortableDeviceContent content;

            this._device.Content(out content);

            var variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();

            StringToPropVariant(file.Id, out variant);

            PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds =
                new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
            objectIds.Add(variant);

            content.Delete(0, objectIds, null);
        }
Beispiel #5
0
        public void DeleteFolder(PortableDeviceFolder folder)
        {
            try
            {
                IPortableDeviceContent content;
                this._device.Content(out content);

                var variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();
                StringToPropVariant(folder.Id, out variant);

                PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds =
                    new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                    as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
                objectIds.Add(variant);

                content.Delete(0, objectIds, null);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #6
0
        public bool CopyInsideWPD(PortableDeviceFile file, string destinationFolderId)
        {
            bool success = false;

            PortableDeviceApiLib.tag_inner_PROPVARIANT variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();
            StringToPropCopyVariant(file.Id, out variant);
            PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds = new PortableDeviceTypesLib.PortableDevicePropVariantCollection() as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
            objectIds.Add(variant);

            IPortableDeviceContent content;

            this._device.Content(out content);
            try {
                PortableDeviceApiLib.IPortableDevicePropVariantCollection res = new PortableDeviceTypesLib.PortableDevicePropVariantCollection() as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
                content.Copy(objectIds, destinationFolderId, ref res);
                success = true;
            } catch (Exception ex) {
                MessageBox.Show("CopyInsideWPD(..) - " + ex.Message);
                success = false;
            }
            return(success);
        }
Beispiel #7
0
        public bool DeleteFile(PortableDeviceFile file)
        {
            bool success = false;

            // original
            //            IPortableDeviceContent content;
            //            this._device.Content(out content);
            PortableDeviceApiLib.tag_inner_PROPVARIANT variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();
            StringToPropVariant(file.Id, out variant);
            PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds = new PortableDeviceTypesLib.PortableDevicePropVariantCollection() as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
            objectIds.Add(variant);
            // the next 2 line need to appear AFTER "StringToPropVariant(file.Id, out variant);" - otherwise content is reset to null
            IPortableDeviceContent content;

            this._device.Content(out content);
            try {
                content.Delete(0, objectIds, null);
                success = true;
            } catch {
                success = false;
            }
            return(success);
        }
        public void DeleteFile(PortableDeviceFile file)
        {
            IPortableDeviceContent content;
            this._device.Content(out content);

            var variant = new PortableDeviceApiLib.tag_inner_PROPVARIANT();
            StringToPropVariant(file.Id, out variant);

            PortableDeviceApiLib.IPortableDevicePropVariantCollection objectIds =
                new PortableDeviceTypesLib.PortableDevicePropVariantCollection()
                as PortableDeviceApiLib.IPortableDevicePropVariantCollection;
            objectIds.Add(variant);

            content.Delete(0, objectIds, null);
        }