private static void EnumerateContents(ref IPortableDeviceContent content,
                                              PortableDeviceFolder parent)
        {
            // Get the properties of the object
            IPortableDeviceProperties properties;

            content.Properties(out properties);

            // Enumerate the items contained by the current object
            IEnumPortableDeviceObjectIDs objectIds;

            content.EnumObjects(0, parent.Id, null, out objectIds);

            uint fetched = 0;

            do
            {
                string objectId;

                objectIds.Next(1, out objectId, ref fetched);
                if (fetched > 0)
                {
                    var currentObject = WrapObject(properties, objectId);

                    parent.Files.Add(currentObject);

                    if (currentObject is PortableDeviceFolder)
                    {
                        EnumerateContents(ref content, (PortableDeviceFolder)currentObject);
                    }
                }
            } while (fetched > 0);
        }
        public PortableDeviceFolder GetContents()
        {
            var root = new PortableDeviceFolder("DEVICE", "DEVICE");

            IPortableDeviceContent content;

            this._device.Content(out content);

            string serialnumber = GetDeviceSerialNumber();

            EnumerateContents(ref content, root);

            return(root);
        }
Beispiel #3
0
        private void DisplayFolderContents(PortableDevice device, PortableDeviceFolder folder)
        {
            if (isdeleteoperation == false && isfetchingrunning == true)
            {
                foreach (var item in folder.Files)
                {
                    //Console.WriteLine(item.Id);

                    if (item is PortableDeviceFolder)
                    {
                        DisplayFolderContents(device, (PortableDeviceFolder)item);
                    }
                    if (item is PortableDeviceFile)
                    {
                        if (!devicestate)
                        {
                            break;
                        }
                        RealDownloadOperation(device, (PortableDeviceFile)item);
                    }
                }
            }

            if (isdeleteoperation == true && isfetchingrunning == false)
            {
                foreach (var item in folder.Files)
                {
                    if (item is PortableDeviceFolder)
                    {
                        DisplayFolderContents(device, (PortableDeviceFolder)item);
                    }



                    if (item is PortableDeviceFile)
                    {
                        if (!devicestate)
                        {
                            break;
                        }

                        RealDeleteOperation(device, (PortableDeviceFile)item, _deletedFiles, _willbeuploaded);
                    }
                }
            }
        }