Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create one dimension array from two using LINQ?

Tags:

c#

linq

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?

like image 459
Arsen Mkrtchyan Avatar asked Mar 01 '11 13:03

Arsen Mkrtchyan


2 Answers

string[] dirFiles = dirs.SelectMany(Directory.GetFiles).ToArray();
like image 125
Heini Høgnason Avatar answered Oct 23 '22 09:10

Heini Høgnason


string[] dirFiles = dirs.SelectMany(Directory.GetFiles).ToArray();
like image 7
Marc Gravell Avatar answered Oct 23 '22 07:10

Marc Gravell