1

代码:

string[] arrFileEntries = Directory.GetFiles(MapPath("..\\Pictures\\"), "*.jpg", "*.png");

错误:

与重载方法 System.IO.Directory.GetFiles (string, string, System.IO.SearchOption) 最接近的匹配有一些无效参数

4

2 回答 2

2

You try below code using linqu:-

var files = Directory.GetFiles(MapPath("..\\Pictures\\"), "*.*", SearchOption.AllDirectories)
            .Where(s => s.EndsWith(".jpg") || s.EndsWith(".png"));
于 2013-03-21T10:33:15.420 回答
1

尝试以下.......获取两个数组中的数据并将它们合并

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);
于 2013-03-21T10:35:36.930 回答