Reputation: 269
Code:
string[] arrFileEntries = Directory.GetFiles(MapPath("..\\Pictures\\"), "*.jpg", "*.png");
Error:
The closest match to the overloaded method System.IO.Directory.GetFiles (string, string, System.IO.SearchOption) has some invalid arguments
Upvotes: 1
Views: 84
Reputation: 1527
try the following.......get data in two array and merge them
string[] array1 = Directory.GetFiles(@"C:\", "*.jpg");
string[] array2 = Directory.GetFiles(@"C:\", "*.png");
string[] newArray = new string[array1.Length + array2.Length];
Array.Copy(array1, newArray, array1.Length);
Array.Copy(array2, 0, newArray, array1.Length, array2.Length);
Upvotes: 1
Reputation: 84
You try below code using linqu:-
var files = Directory.GetFiles(MapPath("..\\Pictures\\"), "*.*", SearchOption.AllDirectories)
.Where(s => s.EndsWith(".jpg") || s.EndsWith(".png"));
Upvotes: 2