IHierarchyItem.Delete Method (LockUriTokenPair[])

IT Hit WebDAV for .NET

Deletes this item.

[Visual Basic]
Sub Delete( _
   ByVal lockTokens As LockUriTokenPair() _
)
[C#]
void Delete(
   LockUriTokenPair[] lockTokens
);

Parameters

lockTokens
Lock tokens for this item or any locked child item.

Exceptions

Exception Type Condition
LockedException This folder or any child item is locked and no or invalid lock token was specified.
ForbiddenException User has not enough rights to perform this operation.
MethodNotAllowedException Trying to delete lock-null item. Lock-null items must be deleted using Unlock method.
WebDavHttpException Server returned unknown error.
WebDavException Unexpected error occurred.

Example

 IHierarchyItem item = session.OpenFolder(new Uri("http://vova:8580/Sales/"));
 LockInfo lockInfo1 = item.Lock(LockScope.Shared, true, "User 1", new TimeSpan(6, 0, 0));

 IHierarchyItem resource = session.OpenResource(new Uri("http://vova:8580/Sales/Austria/report.docx"));
 LockInfo lockInfo2 = resource.Lock(LockScope.Shared, true, "User 1", new TimeSpan(6, 0, 0));

 LockUriTokenPair[] locks = new LockUriTokenPair[2];
 locks[0] = lockInfo1.LockToken;
 locks[1] = lockInfo2.LockToken;

 try
 {
     item.Delete(locks);
 }
 catch (WebDavHttpException ex)
 {
     Console.WriteLine(ex.Message + " " + ex.Status.Code + " " + ex.Status.Description);
     foreach (IMultistatusResponse resp in ex.Multistatus.Responses)
     { // Find which items failed to delete.
         Console.WriteLine(resp.Href + " " + resp.Status.Code + " " + resp.Status.Description);
     }
 }
 

See Also

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