#region 使用递归查询某路径中的文件结构

         public static void CheckFilePath()
{
ReadFilePath(@"E:\Test",);
} public static void ReadFilePath(string path,int level)
{
level++;
Console.WriteLine(SpaceM(level)+Path.GetFileName(path));
string[] dirs = Directory.GetFileSystemEntries(path);//获取文件目录和文件名
for (int i = ; i < dirs.Length; i++)
{
if (Directory.Exists(dirs[i]))//如果是文件夹,则进行递归调用
{
ReadFilePath(dirs[i],level);
}
else
{
Console.WriteLine(SpaceM(level) + Path.GetFileName(dirs[i]));//文件则打印
}
}
} //添加级别字符串
private static string SpaceM(int level)
{
StringBuilder sb = new StringBuilder();
for (int i = ; i < level; i++)
{
sb.Append("|--");
}
return sb.ToString();
} #endregion

递归遍历某路径中文件及文件夹,并缩进

C#递归遍历指定目录下文件和文件夹的更多相关文章

  1. go递归打印指定目录下的所有文件及文件夹

    func treedir(fpath string){ // 获取fileinfo if finfo,err := os.Stat(fpath); err == nil { // 判断是不是目录 如果 ...

  2. Linux下如何遍历指定目录下的所有文件并删除指定天数之前创建的文件

    脚本内容如下: #!/bin/bash function delete_file { days=$[$-] for i in `find $dir -type f -ctime +$days` do ...

  3. svnkit递归获取指定目录下的全部文件

    package demo.wc; import java.util.Collection; import java.util.Iterator; import org.tmatesoft.svn.co ...

  4. C# 遍历指定目录下的所有文件及文件夹以及遍历数据库的方法

    // DirectoryInfo di = new DirectoryInfo(@"D:\Test"); // FindFile(di); static void FindFile ...

  5. C# 遍历指定目录下的所有文件及文件夹

    // DirectoryInfo di = new DirectoryInfo(@"D:\Test"); // FindFile(di); static void FindFile ...

  6. perl 遍历指定目录下的所有文件,替换指定文本内容,返回受影响的文件路径

    不会读取 影藏文件 main #!/usr/bin/perl use autodie; use utf8; use Encode qw(decode encode); if(@ARGV ne 3){ ...

  7. 递归删除指定目录下的 .git 文件

    转载自:http://my.oschina.net/armsky/blog/34447 find . -name .git | xargs rm -fr 其中对 xargs 的介绍,可以参照以下内容: ...

  8. golang filepath.Walk遍历指定目录下的所有文件

    package main import ( "fmt" "os" "path/filepath" ) func walkFunc(path ...

  9. c# 获取指定目录下的所有文件并显示在网页上

    参考文献: FileInfo 的使用  https://msdn.microsoft.com/zh-cn/library/system.io.fileinfo_methods(v=vs.110).as ...

随机推荐

  1. csu 1303 Decimal (数论题)

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1303 1303: Decimal Time Limit: 1 Sec  Memory Limit: ...

  2. 首页banner焦点图自动轮播效果

    今天来介绍一下我前两天写一个小任务的时候遇到的一些问题,如果能够有所帮助或者启发,那将是我的荣幸. <div class="banner"> <a class=& ...

  3. 设置Cookie

    var Site=new Object(); Site.Cookie={ _expires:24*3600*1000, _domain:'.gdxxb.com', set:function(name, ...

  4. 时序列数据库武斗大会之 TSDB 名录 Part 1

    [编者按] 刘斌,OneAPM后端研发工程师,拥有10多年编程经验,参与过大型金融.通信以及Android手机操作系的开发,熟悉Linux及后台开发技术.曾参与翻译过<第一本Docker书> ...

  5. DIY Ruby CPU 分析——Part III

    [编者按]作者 Emil Soman,Rubyist,除此之外竟然同时也是艺术家,吉他手,Garden City RubyConf 组织者.本文是 DIY Ruby CPU Profiling 的第二 ...

  6. 《Introduction to Tornado》中文翻译计划——第五章:异步Web服务

    http://www.pythoner.com/294.html 本文为<Introduction to Tornado>中文翻译,将在https://github.com/alioth3 ...

  7. 关于jsp页面是放在webroot目录下和web-inf下优缺点

    CSDN问题: jsp放在webroot目录下 这样就可以让用户直接访问,jsp放在web-inf目录下就必须要通过请求才能访问.因此放在web-inf下jsp页面显得要安全. 既然这样 ,那是不是只 ...

  8. loadrunner java协议脚本要点

    常见问题 1. Error: Thread Context: Call to service of the driver failed, reason - thread context wasn't ...

  9. Eclipse执行Hadoop WordCount

    前期工作 我的Eclipse是安装在Windows下的,通过Eclipse执行程序连接Hadoop, 需要让虚拟机的访问地址和本机的访问地址保持在同一域内,虚拟机的地址更改前面的文章介绍过了,如果想改 ...

  10. coco2d-js 多屏适配相关API

    setDesignResolutionSize() //设计分辨率大小及模式  setContentScaleFactor() //内容缩放因子 setSearchPaths() //资源搜索路径 g ...