日期:2011-04-11  浏览次数:20394 次

using System;
using System.IO;
using System.Collections;

namespace DSclub
{
    /**//// <summary>
    /// DirList 的摘要说明。
    /// </summary>
    public class DirList
    {
        private string strInitFilePath;
        private bool bFatchAll;

        // 构造函数
        public DirList()
        {
            bFatchAll = false;
            strInitFilePath = "C:\\";
        }
        public DirList(string strFilePath)
        {
            bFatchAll = false;
            strInitFilePath = strFilePath;
        }

        // 是否递归出所有的文件
        public bool RecursionFiles
        {
            get
            {
                return bFatchAll;
            }
            set
            {
                bFatchAll = value;
            }
        }

        // 取得文件的函数
        public ArrayList GetFiles()
        {
            return GetFiles(strInitFilePath, bFatchAll);
        }

        public static ArrayList GetFiles(string strPath, bool ResultsAll)
        {
            ArrayList al  = new ArrayList();
            // 判断路径是否存在
            if(!Directory.Exists(strPath))
            {
                throw(new ApplicationException("访问的路径" + strPath + "不存在,或者它不是个文件夹。"));
            }

            string[] temp =  Directory.GetFiles(strPath);
            foreach(string aFile in temp)
            {
                al.Add(aFile);
            }

       &nbs