Click or drag to resize

IHierarchyItemDeleteAsync Method

IT Hit WebDAV Classes Reference
Deletes this item.

Namespace:  ITHit.WebDAV.Server
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 13.3.13068
Syntax
Task DeleteAsync(
	MultistatusException multistatus
)

Parameters

multistatus
Type: ITHit.WebDAV.ServerMultistatusException
If some items fail to delete but operation in whole shall be continued, add information about the error into multistatus using AddInnerException(String, DavException).

Return Value

Type: Task
A task object that can be awaited.
Exceptions
ExceptionCondition
LockedExceptionThis item or its parent was locked and client did not provide lock token.
NeedPrivilegesExceptionThe user doesn't have enough privileges.
InsufficientStorageExceptionQuota limit is reached.
MultistatusExceptionErrors has occured during processing of item in the subtree and whole operation shall be aborted.
DavExceptionIn other cases. Possible status value is CONFLICT if destination folder doesn't exist.
Examples

The code below is part of 'WebDAVServer.FileSystemStorage.AspNet' C# & VB samples provided with the SDK.

public override async Task DeleteAsync(MultistatusException multistatus)
{
    await DeleteInternalAsync(multistatus, 0);
}

public override async Task DeleteInternalAsync(MultistatusException multistatus, int recursionDepth)
{
    await RequireHasTokenAsync();
    if (FileSystemInfoExtension.IsUsingFileSystemAttribute)
    {
        await fileSystemInfo.DeleteExtendedAttributes();
    }
    fileSystemInfo.Delete();
    if (recursionDepth == 0)
    {
        await context.socketService.NotifyDeletedAsync(Path, GetWebSocketID());
    }
}

The code below is part of 'WebDAVServer.FileSystemSynchronization.AspNetCore' C# & VB samples provided with the SDK.

C#
public override async Task DeleteAsync(MultistatusException multistatus)
{
    await DeleteInternalAsync(multistatus, 0);
}

public override async Task DeleteInternalAsync(MultistatusException multistatus, int recursionDepth)
{
    await RequireHasTokenAsync();
    if (FileSystemInfoExtension.IsUsingFileSystemAttribute)
    {
        await fileSystemInfo.DeleteExtendedAttributes();
    }
    if (recursionDepth == 0)
    {
        // hide file, it is needed for sync-collection report.
        fileSystemInfo.Attributes = fileSystemInfo.Attributes | FileAttributes.Hidden;
        using (FileStream fileStream = new FileStream(fileSystemInfo.FullName, FileMode.Truncate))
        {
            fileStream.SetLength(0);
        }
        await context.socketService.NotifyDeletedAsync(Path, GetWebSocketID());
    }
    else
    {
        fileSystemInfo.Delete();
    }
}
See Also