Click or drag to resize

IHierarchyItemDeleteAsync Method (LockUriTokenPair, IDictionaryString, String, CancellationToken)

IT Hit WebDAV Classes Reference
Deletes this item.

Namespace:  ITHit.WebDAV.Client
Assembly:  ITHit.WebDAV.Client (in ITHit.WebDAV.Client.dll) Version: 6.0.4052-Beta
Task DeleteAsync(
	LockUriTokenPair[] lockTokens,
	IDictionary<string, string> headers = null,
	CancellationToken cancellationToken = null


Type: ITHit.WebDAV.ClientLockUriTokenPair
Lock tokens for this item or any locked child item.
headers (Optional)
Type: System.Collections.GenericIDictionaryString, String
Request headers.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
Propagates notification that operations should be canceled.

Return Value

Type: Task

[Missing <returns> documentation for "M:ITHit.WebDAV.Client.IHierarchyItem.DeleteAsync(ITHit.WebDAV.Client.LockUriTokenPair[],System.Collections.Generic.IDictionary{System.String,System.String},System.Threading.CancellationToken)"]

LockedExceptionThis folder or any child item is locked and no or invalid lock token was specified.
ForbiddenExceptionUser has not enough rights to perform this operation.
MethodNotAllowedExceptionTrying to delete lock-null item. Lock-null items must be deleted using [!:IHierarchyItem.UnlockAsync(string)] method.
WebDavHttpExceptionServer returned unknown error.
WebDavExceptionUnexpected error occurred.
IHierarchyItem item = await session.GetFolderAsync(new Uri("http://vova:8580/Sales/"));
LockInfo lockInfo1 = await item.LockAsync(LockScope.Shared, true, "User 1", new TimeSpan(6, 0, 0));

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

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

    await item.DeleteAsync(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