Code /// <summary> /// obtain the names of all objects in the specified folder /// </summary> /// <param name = "folderName"> specify the folder name, absolute path </param> /// <param name = "fileFilter"> filter file types based on the file suffix, for example :*,*. txt ,*. xls </param> /// <param name = "isContainSubFolder"> include subfolders </param> /// <returns> ArrayList array, name of all required file paths </returns> public static ArrayList GetAllFilesByFolder (string folderName, string fileFilter, bool isContainSubFolder) {ArrayList resArray = new ArrayList (); string [] files = Directory. getFiles (folderName, fileFilter); for (int I = 0; I <files. length; I ++) {resArray. add (files [I]);} if (isContainSubFolder) {string [] folders = Directory. getDirectories (folderName); for (int j = 0; j <folders. length; j ++) {// traverse all folders ArrayList temp = GetAllFilesByFolder (folders [j], fileFilter, isContainSubFolder); resArray. addRange (temp) ;}}return resArray ;}/// <summary >/// obtain the names of all objects in the specified folder, do not filter the file type /// </summary> /// <param name = "folderName"> specify the folder name, absolute path </param> /// <param name = "isContainSubFolder"> include subfolders </param> /// <returns> ArrayList array, name of all required file paths </returns> public static ArrayList GetAllFilesByFolder (string folderName, bool isContainSubFolder) {return GetAllFilesByFolder (folderName, "*", isContainSubFolder );}
Programmers are interested in. NET software development, Matlab hybrid programming, and network technology.
Welcome to my Cnblog blog: http://www.cnblogs.com/asxinyu/
Welcome to our discussion. QQ: 1287263703
E-mail: asxinyu@qq.com, asxinyu@126.com
Tag: Matlab, Matlab development, Matlab hybrid programming, C #. NET Development