获取多个目录中的文件 [英] get files from multiple directories

查看:77
本文介绍了获取多个目录中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的文件列表到多个目录数组或列表



目前我在做什么:

  tempbatchaddresses = Directory.GetFiles(@C:\,* .LOG); 



但我还需要 tempbatchaddresses + = Directory.GetFiles(@D: \,* .LOG);



和第三个为好。我需要从3个不同的目录中添加文件的文件位置。



我如何做到这一点?


解决方案

  tempBatchAddresses = Directory.GetFiles(@C:\,* .LOG)。了ToList(); 

tempBatchAddresses.AddRange(Directory.GetFiles(@D:\,* .LOG)了ToList());

tempBatchAddresses.AddRange(Directory.GetFiles(一些目录,某种模式)了ToList());



等..


i am trying to get a list of files into an array or list from multiple directories

currently i am doing:

tempbatchaddresses = Directory.GetFiles(@"c:\", "*.log");

but i also need tempbatchaddresses += Directory.GetFiles(@"d:\", "*.log");

and a third one as well. i need to add the file locations of files from 3 different directories.

how do i do this?

解决方案

tempBatchAddresses = Directory.GetFiles(@"c:\", "*.log").ToList();

tempBatchAddresses.AddRange(Directory.GetFiles(@"d:\", "*.log").ToList());

tempBatchAddresses.AddRange(Directory.GetFiles("some dir", "some pattern").ToList());

and so on ..

这篇关于获取多个目录中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆