Click or drag to resize

IFolderCreateLockNullAsync Method (String, LockScope, Boolean, String, TimeSpan, IDictionaryString, String, CancellationToken)

IT Hit WebDAV Classes Reference
Locks name for later use.

Namespace:  ITHit.WebDAV.Client
Assembly:  ITHit.WebDAV.Client (in ITHit.WebDAV.Client.dll) Version: 6.0.4052-Beta
Task<LockInfo> CreateLockNullAsync(
	string newItemName,
	LockScope lockScope,
	bool deep,
	string owner,
	TimeSpan timeout,
	IDictionary<string, string> headers = null,
	CancellationToken cancellationToken = null


Type: SystemString
Name of new item.
Type: ITHit.WebDAV.ClientLockScope
Scope of the lock.
Type: SystemBoolean
Whether to lock entire subtree.
Type: SystemString
Owner of the lock.
Type: SystemTimeSpan
TimeOut after which lock expires.
headers (Optional)
Type: System.Collections.GenericIDictionaryString, String
Request headers.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
Propagates notification that operations should be canceled.

Return Value

Type: TaskLockInfo
Instance of LockInfo with information about created lock.
NotFoundExceptionThis folder doesn't exist on the server.(Server in fact returns Conflict)
LockedExceptionThis folder is locked and no or invalid lock token was specified.
ForbiddenExceptionThe client, for reasons the server chooses not to specify, cannot apply the lock.
WebDavHttpExceptionServer returned unknown error.
WebDavExceptionUnexpected error occurred.
Locks name for later use creating a lock-null item with a specified name. Later lock-null item could be converted to a resource calling CreateFileAsync(String) or converted to a folder calling CreateFolderAsync(String). Lock-null items cannot be deleted using [!:IHierarchyItem.DeleteAsync()] method, call [!:IHierarchyItem.UnlockAsync(string)] instead.
IFolder folder = await session.GetFolderAsync(new Uri("https://server:8080/Sales"));
LockInfo lockInfo = await folder.CreateLockNullAsync("file1.gif",
    LockScope.Exclusive, true, "User 1", new TimeSpan(0, 30, 0)); // reserve name for future use
Uri RemoteStorageUri = new Uri("https://server:8080/Sales/file1.gif");
LockUriTokenPair[] lockTokens = new LockUriTokenPair[] { new LockUriTokenPair(RemoteStorageUri, lockInfo.LockToken.LockToken) };
IFile file = await folder.CreateFileAsync("file1.gif", lockTokens); // convert lock-null to resource
await file.UnlockAsync(lockTokens);
See Also