如:
有一目录:c:\zzm ,
它下面存有多个*.real文件,如何把这些文件名给一个ArrayList对象存放

解决方案 »

  1.   

    protected void GetFiles(String strDir, String strExt, bool bRecursive)
              {
                DirectoryInfo dir = new DirectoryInfo(strDir);
                FileInfo[] fileList = dir.GetFiles("*." + strExt);
                     for(int i=0; i<fileList.Length; i++)
                {
                    if(fileList[i].Exists)
                        m_arrFiles.Add(strDir + "\\" + fileList[i].Name);
                }
                if(bRecursive==true)
                {
                    //Get recursively from subdirectories
                    DirectoryInfo[] dirList = dir.GetDirectories();
                    for(int i=0; i<dirList.Length; i++)
                    {
                        GetFiles(strDir + "\\" + dirList[i].Name, strExt, bRecursive);
                    }
                }
            }
      

  2.   

    关键就一句 Dirs.GetFiles("*.real");