Click or drag to resize

IItemCollectionAsyncGetChildrenAsync Method

IT Hit WebDAV Classes Reference
Gets direct children of this folder.

Namespace:  ITHit.WebDAV.Server
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 9.1.5460-Beta
Syntax
Task<PageResults> GetChildrenAsync(
	IList<PropertyName> propNames,
	Nullable<long> offset,
	Nullable<long> nResults,
	IList<OrderProperty> orderProps
)

Parameters

propNames
Type: System.Collections.GenericIListPropertyName
List of properties requested by the client.
offset
Type: SystemNullableInt64
The number of items to skip before returning the remaining items.
nResults
Type: SystemNullableInt64
The number of items to return.
orderProps
Type: System.Collections.GenericIListOrderProperty
List of order properties requested by the client.

Return Value

Type: TaskPageResults
Instance of PageResults class that contains items on a requested page and total number of items in a folder.
Examples

The code below is part of 'WebDAVServer.FileSystemStorage.AspNet' C# & VB samples provided with the SDK.

public virtual async Task<PageResults> GetChildrenAsync(IList<PropertyName> propNames, long? offset, long? nResults, IList<OrderProperty> orderProps)
{
    // Enumerates all child files and folders.
    // You can filter children items in this implementation and 
    // return only items that you want to be visible for this 
    // particular user.

    IList<IHierarchyItemAsync> children = new List<IHierarchyItemAsync>();

    long totalItems = 0;
    FileSystemInfo[] fileInfos = dirInfo.GetFileSystemInfos();
    totalItems = fileInfos.Length;

    // Apply sorting.
    fileInfos = SortChildren(fileInfos, orderProps);

    // Apply paging.
    if (offset.HasValue && nResults.HasValue)
    {
        fileInfos = fileInfos.Skip((int)offset.Value).Take((int)nResults.Value).ToArray();
    }

    foreach (FileSystemInfo fileInfo in fileInfos)
    {
        string childPath = Path + EncodeUtil.EncodeUrlPart(fileInfo.Name);
        IHierarchyItemAsync child = await context.GetHierarchyItemAsync(childPath);
        if (child != null)
        {
            children.Add(child);
        }
    }

    return new PageResults(children, totalItems);
}
See Also