예제 #1
0
        private void StringToPropVariant(string objectId, out PortableDeviceApiLib.tag_inner_PROPVARIANT pv)
        {
            IPortableDeviceValues values = (PortableDeviceApiLib.IPortableDeviceValues) new PortableDeviceTypesLib.PortableDeviceValues();

            values.SetStringValue(ref pKey.WPD_OBJECT_ID, objectId);
            values.GetValue(ref pKey.WPD_OBJECT_ID, out pv);
        }
예제 #2
0
        internal Item CreateSubdirectory(string path)
        {
            Item child   = null;
            Item parent  = this;
            var  folders = path.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var folder in folders)
            {
                child = parent.GetChildren().FirstOrDefault(i => device.EqualsName(i.Name, folder));
                if (child == null)
                {
                    // create a new directory
                    IPortableDeviceValues deviceValues = (IPortableDeviceValues) new PortableDeviceValues();
                    deviceValues.SetStringValue(ref WPD.OBJECT_PARENT_ID, parent.Id);
                    deviceValues.SetStringValue(ref WPD.OBJECT_NAME, folder);
                    deviceValues.SetStringValue(ref WPD.OBJECT_ORIGINAL_FILE_NAME, folder);
                    deviceValues.SetGuidValue(ref WPD.OBJECT_CONTENT_TYPE, ref WPD.CONTENT_TYPE_FOLDER);
                    string id = string.Empty;
                    this.device.deviceContent.CreateObjectWithPropertiesOnly(deviceValues, ref id);
                    child = Item.Create(this.device, id, parent.FullName);
                }
                else if (child.Type == ItemType.File)
                {
                    // folder is already a file
                    throw new Exception($"A path of the path {folder} is a file");
                }
                else
                {
                    // folder exists
                    //id = child.Id;
                    //new Item()

                    // TODO
                }
                parent = child;
            }
            return(child);
        }
예제 #3
0
        private void StringToPropVariant(string value,
                                         out PortableDeviceApiLib.tag_inner_PROPVARIANT propvarValue)
        {
            // We'll use an IPortableDeviceValues object to transform the
            // string into a PROPVARIANT
            PortableDeviceApiLib.IPortableDeviceValues pValues =
                (PortableDeviceApiLib.IPortableDeviceValues)
                new PortableDeviceTypesLib.PortableDeviceValuesClass();

            // We insert the string value into the IPortableDeviceValues object
            // using the SetStringValue method
            pValues.SetStringValue(ref PortableDevicePKeys.WPD_OBJECT_ID, value);

            // We then extract the string into a PROPVARIANT by using the
            // GetValue method
            pValues.GetValue(ref PortableDevicePKeys.WPD_OBJECT_ID,
                             out propvarValue);
        }