如何访问给定文件夹中的每个文件夹

编程入门 行业动态 更新时间:2024-10-27 16:31:57
本文介绍了如何访问给定文件夹中的每个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

朋友们.我有一个文件夹,其中有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"));

(如果参考问题"页面,请参阅说明.)

—SA

(See the explanation if the references Question page.)

—SA

更多推荐

如何访问给定文件夹中的每个文件夹

本文发布于:2023-10-31 16:47:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   文件   夹中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!