namespace copefile { class Program { static void Main(st " /> 色综合色狠狠天天综合色,秋霞毛片久久久久久久久,亚洲欧美成人综合

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net遍歷目錄文件夾和子目錄所有文件

復制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;

namespace copefile
{
    class Program
    {
        static void Main(string[] args)
        {
            string testDir = "e:/xunlei/";
            listFiles(testDir,0);
            Console.ReadKey();
        }

        public static void listFiles(string dir, int level)
        {
           //阿會楠練習作品,程序多有參考
            try
            {
                //獲取文件列表
                string[] files = Directory.GetFiles(dir);

                String preStr = "";
                for (int i = 0; i < level; i++)
                {
                    preStr += "    ";
                }

                foreach (string f in files)
                {
                    if (f.LastIndexOf("http://") == -1)
                    {
                        Console.WriteLine(preStr + f.Substring(f.LastIndexOf("/") + 1));
                    }
                    else
                    {
                        Console.WriteLine(preStr + f.Substring(f.LastIndexOf("http://") + 1));
                    }

                }

                //獲取目錄列表
                string[] dirs = Directory.GetDirectories(dir);
                foreach (string d in dirs)
                {
                    if (d.LastIndexOf("http://") == -1)
                    {
                        Console.WriteLine(preStr + d.Substring(d.LastIndexOf("/") + 1));
                    }
                    else
                    {
                        Console.WriteLine(preStr + d.Substring(d.LastIndexOf("http://") + 1));
                    }
                    if (Directory.Exists(d))
                    {
                        listFiles(d, level + 1);
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

AspNet技術asp.net遍歷目錄文件夾和子目錄所有文件,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 南木林县| 保康县| 西丰县| 铜山县| 普安县| 梁平县| 息烽县| 松潘县| 土默特左旗| 木兰县| 朔州市| 邻水| 兰坪| 林甸县| 枝江市| 遵化市| 抚顺县| 盐亭县| 房产| 囊谦县| 桂东县| 成武县| 灵璧县| 涟水县| 称多县| 龙陵县| 海伦市| 东方市| 杭锦后旗| 吴川市| 塘沽区| 枣阳市| 时尚| 赤城县| 汝州市| 巩义市| 德江县| 洛浦县| 武胜县| 炉霍县| 沾化县|