Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET
>
Tutorial
> Lock and unlock files and folders
The following example shows you how to lock and unlock file or folder.
C# example
using System; using System.Net; using Independentsoft.Webdav; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); WebdavSession session = new WebdavSession(credential); Resource resource = new Resource(session); //Lock file for 10 minutes ActiveLock fileLock = resource.Lock("http://myserver/dav/file1.dat", Depth.Zero, 600); //Unlock file resource.Unlock("http://myserver/dav/file1.dat", fileLock); } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Webdav Namespace Sample Class Module1 Shared Sub Main(ByVal args() As String) Dim credential As NetworkCredential = New NetworkCredential("username", "password") Dim session As WebdavSession = New WebdavSession(credential) Dim resource As Resource = New Resource(session) 'Lock file for 10 minutes Dim fileLock As ActiveLock = resource.Lock("http://myserver:8080/dav/file1.dat", Depth.Zero, 600) 'Unlock file resource.Unlock("http://myserver:8080/dav/file1.dat", fileLock) End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*