IHierarchyItem.UpdateProperties Method (Property[], PropertyName[])

IT Hit WebDAV for .NET

Updates values of properties exposed by this item.

[Visual Basic]
Sub UpdateProperties( _
   ByVal propertiesToAddOrUpdate As Property(), _
   ByVal propertiesToDelete As PropertyName() _
)
[C#]
void UpdateProperties(
   Property[] propertiesToAddOrUpdate,
   PropertyName[] propertiesToDelete
);

Parameters

propertiesToAddOrUpdate
Properties to be updated.
propertiesToDelete
Names of properties to be removed from this item.

Exceptions

Exception Type Condition
LockedException The item is locked and no or invalid lock token was provided.
PropertyForbiddenException Cannot alter one of the properties.
PropertyConflictException The client has provided a value whose semantics are not appropriate for the property. This includes trying to set read-only properties.
NotFoundException This item doesn't exist on the server.
ConflictException The resource is version controlled and has to be checked out to be edited.
PropertyException Server returned unknown error for specific property.
WebDavHttpException Server returned unknown error.
WebDavException Unexpected error occurred.

Example

 string license = "<?xml version='1.0' encoding='utf...
 WebDavSession session = new WebDavSession(license);
 session.Credentials = new NetworkCredential("User1", "pwd");
 IResource resource = session.OpenResource(new Uri("https://server/Library/doc.txt"));

 Property[] propsToAddAndUpdate = new Property[3];
 propsToAddAndUpdate[0] = new Property(new PropertyName("Ammount", "CorpNS"), "1200");
 propsToAddAndUpdate[1] = new Property(new PropertyName("ManagerApproved", "Sales"), "Yes");
 propsToAddAndUpdate[2] = new Property(new PropertyName("Branch", "Sales"), "EMEA Region");

 PropertyName[] propsToDelete = new PropertyName[2];
 propsToDelete[0] = new PropertyName("InternalName", "Sales");
 propsToDelete[1] = new PropertyName("Counter", "CorpNS");

 try
 {
     resource.UpdateProperties(propsToAddAndUpdate, propsToDelete);
 }
 catch(PropertyException ex)
 {
     Console.WriteLine(ex.Message + " " + ex.Status.Code + " " + ex.Status.Description);
     // Find which properties failed to add/update/delete
     foreach (IPropertyMultistatusResponse propInfo in ex.Multistatus.Responses)
     {
         Console.WriteLine(propInfo.PropertyName + " " + propInfo.Status.Code + " " + propInfo.Status.Description);
     }
 }
 

See Also

IHierarchyItem Interface | ITHit.WebDAV.Client Namespace | IHierarchyItem.UpdateProperties Overload List