Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# IContentItem.SetImagePropertyValue Method

Updates the value of the `IImageProperty`.

void SetImagePropertyValue(
IBaseProperty imageProperty,
string imageName,
Stream value
);

#### Parameters

imageProperty
  The `IImageProperty`; cannot be `null`.
imageName
  The name of the image to be uploaded as the value of the specified image property; cannot be `null`, empty, or longer than 255 characters.
value
  The new value for the property; cannot be `null`.

#### Remarks

An `InvalidOperationException` will be thrown if this method is called on an item that is not checked-out. The updated property value will not be persisted until `IContentItemManager.CheckInItem` is called. If the content item does not contain the specified property an `ArgumentException` will be thrown when `IContentItemManager.CheckInItem` is called.

Note: To use any file upload/download functionality, including this using method, you must install WSE 2.0 (http://msdn.microsoft.com/webservices/building/wse/).

The code sample below shows how to set the `IFileProperty` value to the content of an existing file.

    FileStream image = new FileStream("C:\\uploads\\image.jpg", FileMode.Open);
    contentItem.SetImagePropertyValue(imageProperty, "myImage.jpg", image);
    // The name of the image can be set to a different name from the actual image name, such as,
    // contentItem.SetImagePropertyValue(imageProperty, "someOtherName.jpg", image);

    // Checks-in the content item to persist the updated ImageProperty value.
    itemManager.CheckInItem(contentItem, "Check-in Comment");

    // Retrieves the image, image name, height and width after the item is checked-in.
    Stream retrievedImage = contentItem.GetImagePropertyValue(imageProperty);
    String retrievedImageName = contentItem.GetImageName(imageProperty);
    int imageWidth = contentItem.GetImageWidth(imageProperty);
    int imageHeight = contentItem.GetImageHeight(imageProperty);

See code sample in IContentItem class documentation on how to modify property value of different types.

#### Exceptions

Exception Type | Condition
--- | ---
InvalidOperationException | The item has already been removed or the item is not checked-out.
ArgumentException | The item does not contain the specified property, or if the image name is an empty string or longer than 255 characters.

#### See Also

IContentItem Interface | Plumtree.Remote.PRC.Content.Item Namespace | CheckInItem