Example #1
0
        public static async Task <IDirectoryInfo> FindDirectoryAsync(this IDirectoryInfo di, string name, CancellationToken ct)
        {
            if (di == null)
            {
                throw new ArgumentNullException(nameof(di));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var children = await di.GetItemsAsync(ct);

            foreach (var child in children.OfType <IDirectoryInfo>())
            {
                if (!child.IsDirectory())
                {
                    continue;
                }

                if (string.Equals(child.Name, name, StringComparison.OrdinalIgnoreCase))
                {
                    return(child);
                }
            }

            return(null);
        }
Example #2
0
        public async Task <IReadOnlyCollection <IFileSystemInfo> > GetItemsAsync(CancellationToken ct)
        {
            var items = await _directoryInfo.GetItemsAsync(ct).ConfigureAwait(false);

            return(items.Select(Convert).ToList());
        }