var ext = new List<string> { ".jpg", ".gif", ".png" };
var myFiles = Directory.GetFiles(directory, "*.*", SearchOption.AllDirectories)
.Where(s => ext.Any(e => s.EndsWith(e)));
CopyFilesToClipBoard()
方法CopyFilesToClipBoard()
public static string[] CopyFilesToClipBoard(List<string> file_list)
{
foreach (string file_name in Directory.GetFiles(Application.StartupPath))
file_list.Add(file_name);
Clipboard.Clear();
Clipboard.SetData(DataFormats.FileDrop, file_list.ToArray());
string[] file_names = (string[])
Clipboard.GetData(DataFormats.FileDrop);
return file_names;
}
问题是CopyFilesToClipBoard应该获取List但是var myFiles是IEnumerable
答案 0 :(得分:4)
您可以调用ToList
方法:
CopyFilesToClipBoard(myFiles.ToList());