本文介绍了如何访问给定文件夹中的每个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
—SA
—SA
朋友们.我有一个文件夹,其中有4-5个文件夹.我想在每个文件夹中修改一个名为"kkj"的文件.我不知道如何处理主文件夹中的子文件夹.请帮我这样做. 非常感谢您
Hi Friends. I have a folder in which there are 4-5 folders. I want to modify a file of name "kkj" in each folder. I don''t know how to deal the sub folders in the main folder as an iteration. Please help me doing this. Thank you so much
推荐答案请使用此方法 System.IO.Directory.GetFiles(String,String,SearchOption) [ ^ ]. 这使您可以递归搜索目录.适用于.NET 2.0、3.0、3.5、4.0. 干杯! Please use this method System.IO.Directory.GetFiles(String, String, SearchOption)[^]. This will let you search a directory recursively. Works in .NET 2.0, 3.0, 3.5, 4.0. Cheers!
此 [ ^ ]小代码段肯定会对您有所帮助. This[^] little code snippet should surely help you.
此外,Manfred和Abhinav的答案:与微软如何对待口罩有关的一个难题是违反直觉的.请参阅以下讨论: Directory.Get.Files搜索模式问题 [ ^ ]. 请注意以下代码示例中的Where和ToLower: In addition the the Answers by Manfred and Abhinav: there is one difficulty related to how Microsoft treats the masks, it is counter-intuitive. Please see this discussion: Directory.Get.Files search pattern problem[^]. Pay attention to Where and ToLower in this code sample: var files = Directory.GetFiles( dir, "*.exe"). Where(item => item.ToLower().EndsWith(".exe"));
(如果参考问题"页面,请参阅说明.)
(See the explanation if the references Question page.)
更多推荐
如何访问给定文件夹中的每个文件夹
发布评论