Namespace: ITHit.WebDAV.Server
Task<PageResults> GetChildrenAsync( IList<PropertyName> propNames, Nullable<long> offset, Nullable<long> nResults, IList<OrderProperty> orderProps )
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<IHierarchyItem> children = new List<IHierarchyItem>(); 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); IHierarchyItem child = await context.GetHierarchyItemAsync(childPath); if (child != null) { children.Add(child); } } return new PageResults(children, totalItems); }
The code below is part of 'WebDAVServer.FileSystemSynchronization.AspNetCore' 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<IHierarchyItem> children = new List<IHierarchyItem>(); long totalItems = 0; FileSystemInfo[] fileInfos = dirInfo.GetFileSystemInfos().Where(p => !p.Attributes.HasFlag(FileAttributes.Hidden)).ToArray(); 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); IHierarchyItem child = await context.GetHierarchyItemAsync(childPath); if (child != null) { children.Add(child); } } return new PageResults(children, totalItems); }