8

I have an array of directory paths, and want to get all

string[] dirs = ...;
string[][] dirFiles = dirs.Select(Directory.GetFiles).ToArray();

Now I want to get the list of files in one dimension array, is it possible to convert this array to one dimension? And in general, is it possible to convert two dimension array to one by joining all togather using linq?

2 Answers 2

19
string[] dirFiles = dirs.SelectMany(Directory.GetFiles).ToArray();
Sign up to request clarification or add additional context in comments.

Comments

7
string[] dirFiles = dirs.SelectMany(Directory.GetFiles).ToArray();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.