ILock.Unlock Method 

IT Hit WebDAV for .NET

Removes lock with the specified token from this item or deletes lock-null item.

[Visual Basic]
Function Unlock( _
   ByVal lockToken As String _
) As WebDAVResponse
[C#]
WebDAVResponse Unlock(
   string lockToken
);

Parameters

lockToken
Lock with this token should be removed from the item.

Return Value

Remarks

If this lock included more than one hierarchy item, the lock is removed from all items included in the lock. If the lock-null item is unlocked using this method then it must be removed from the WebDAV hierarchy.

Example

public WebDAVResponse Unlock(string lockToken)
{
    LockInfo[] locks = ActiveLocks;
    int i;
    
    for(i=0;i<locks.Length;i++)
        if(locks[i].Token == lockToken) break;
    
    if(i == locks.Length)
        return new PreconditionFailedResponse();

    if(this is ILockNull)
    { // delete lock-null item
        DeleteThisItem();
    }
    else
    { // remove lock from existing item
        SqlConnection conn = new SqlConnection(connStr);
        SqlCommand cmd;
        conn.Open();
        try
        {
            cmd = conn.CreateCommand();
            cmd.CommandText = "DELETE FROM Lock WHERE Token LIKE @Token";
            cmd.Parameters.Add("@Token", SqlDbType.NVarChar).Value = lockToken;
            cmd.ExecuteNonQuery();
        }
        finally
        {
            conn.Close();
        }
    }
    
    return new NoContentResponse();
}
 

See Also

ILock Interface | ITHit.WebDAV.Server Namespace