コード例 #1
0
ファイル: Item.cs プロジェクト: chcg/MediaDevices
        internal void UploadFile(string fileName, Stream stream)
        {
            IPortableDeviceValues portableDeviceValues = new PortableDeviceValues() as IPortableDeviceValues;

            portableDeviceValues.SetStringValue(ref WPD.OBJECT_PARENT_ID, this.Id);
            portableDeviceValues.SetUnsignedLargeIntegerValue(ref WPD.OBJECT_SIZE, (ulong)stream.Length);
            portableDeviceValues.SetStringValue(ref WPD.OBJECT_ORIGINAL_FILE_NAME, fileName);
            portableDeviceValues.SetStringValue(ref WPD.OBJECT_NAME, fileName);
            // test
            using (PropVariantFacade now = PropVariantFacade.DateTimeToPropVariant(DateTime.Now))
            {
                portableDeviceValues.SetValue(ref WPD.OBJECT_DATE_CREATED, ref now.Value);
                portableDeviceValues.SetValue(ref WPD.OBJECT_DATE_MODIFIED, ref now.Value);

                uint   num  = 0u;
                string text = null;
                this.device.deviceContent.CreateObjectWithPropertiesAndData(portableDeviceValues, out IStream wpdStream, ref num, ref text);

                using (StreamWrapper destinationStream = new StreamWrapper(wpdStream))
                {
                    stream.CopyTo(destinationStream);
                    destinationStream.Flush();
                }
            }
        }
コード例 #2
0
ファイル: Item.cs プロジェクト: chcg/MediaDevices
        internal void SetDateAuthored(DateTime value)
        {
            IPortableDeviceValues portableDeviceValues = new PortableDeviceValues() as IPortableDeviceValues;
            IPortableDeviceValues result;

            using (PropVariantFacade val = PropVariantFacade.DateTimeToPropVariant(value))
            {
                portableDeviceValues.SetValue(ref WPD.OBJECT_DATE_AUTHORED, ref val.Value);
                this.device.deviceProperties.SetValues(this.Id, portableDeviceValues, out result);
                ComTrace.WriteObject(result);
            }

            Refresh();
        }