Click or drag to resize

WebDavSessionGetItemAsync Method (String, IDictionaryString, String, CancellationToken)

IT Hit WebDAV Classes Reference
Returns IHierarchyItem corresponding to path.

Namespace:  ITHit.WebDAV.Client
Assembly:  ITHit.WebDAV.Client (in ITHit.WebDAV.Client.dll) Version: 6.0.4052-Beta
Syntax
public Task<IHierarchyItem> GetItemAsync(
	string path,
	IDictionary<string, string> headers = null,
	CancellationToken cancellationToken = null
)

Parameters

path
Type: SystemString
Path to the item.
headers (Optional)
Type: System.Collections.GenericIDictionaryString, String
Request headers.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
Propagates notification that operations should be canceled.

Return Value

Type: TaskIHierarchyItem
Item corresponding to requested path.

Implements

ISessionGetItemAsync(String, IDictionaryString, String, CancellationToken)
Exceptions
ExceptionCondition
UnauthorizedExceptionIncorrect credentials provided or insufficient permissions to access the requested item.
NotFoundExceptionThe requested folder doesn't exist on the server.
ForbiddenExceptionThe server refused to fulfill the request.
WebDavExceptionUnexpected error occurred.
Examples
string license = "<?xml version='1.0' encoding='utf...
WebDavSession session = new WebDavSession(license, new HttpClientHandler() { Credentials = new NetworkCredential("User1", "pwd") });

IHierarchyItem item = null;
try
{
    item = await session.GetItemAsync("https://server/Products/new.zip");
}
catch(UnauthorizedException)
{
    Console.WriteLine("Incorrect user name or password.");
}
catch(NotFoundException)
{
    Console.WriteLine("Item was not found.");
}

if (item != null)
{
    Console.WriteLine(item.LastModified.ToString());
}
See Also