Independentsoft
Home
Purchase
Support
Company
Contact
WebDAV .NET
>
Tutorial
> Check file and folder existence
The following example shows you how to check whether a file or folder exists.
C# example
using System; using System.Net; using System.Threading.Tasks; using Independentsoft.Webdav; namespace Sample { class Program { static async Task Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); using (WebdavClient client = new WebdavClient(credential)) { client.BaseAddress = new Uri("https://myserver/dav/"); Console.WriteLine("documents/report.pdf exists: " + await client.Exists("documents/report.pdf")); Console.WriteLine("documents/ exists: " + await client.Exists("documents/")); Console.WriteLine("documents/missing.pdf exists: " + await client.Exists("documents/missing.pdf")); } } } }
VB example
Imports System Imports System.Net Imports System.Threading.Tasks Imports Independentsoft.Webdav Namespace Sample Module Program Sub Main(args As String()) RunAsync().GetAwaiter().GetResult() End Sub Private Async Function RunAsync() As Task Dim credential As New NetworkCredential("username", "password") Using client As New WebdavClient(credential) client.BaseAddress = New Uri("https://myserver/dav/") Console.WriteLine("documents/report.pdf exists: " & Await client.Exists("documents/report.pdf")) Console.WriteLine("documents/ exists: " & Await client.Exists("documents/")) Console.WriteLine("documents/missing.pdf exists: " & Await client.Exists("documents/missing.pdf")) End Using End Function End Module End Namespace
Need help? Ask our developers:
Name*
Email*
Message*