Skip to content

Getting All Child ListItem Objects in a Folder #1428

Answered by adamfisher
adamfisher asked this question in Q&A
Discussion options

You must be logged in to vote

Ok after beating on this some more this seems to have worked:

/// <summary>
/// Gets all the child items within the specified folder up to the maximum depth.
/// </summary>
/// <param name="folder">The folder to scan for items.</param>
/// <param name="maxDepth">The maximum depth to return items for.</param>
/// <param name="objectTypes">The type of items to return.</param>
public static async Task<List<IListItem>> GetChildItemsAsync(this IFolder folder,
	int maxDepth = 20,
	params FileSystemObjectType[]? objectTypes)
{
	List<IListItem> items = new();
	Queue<(IFolder folder, int depth)> queue = new();
	objectTypes = objectTypes.IsNullOrEmpty() ? new[] { FileSystemObjectType.File, FileSyst…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Amwins-Bass-Guy
Comment options

@adamfisher
Comment options

Answer selected by adamfisher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants