The below code is in .NET C#
public ArrayList GetAllFiles(string directory)
{
ArrayList totalFilesList = new ArrayList(10);
string[] files = Directory.GetFiles(directory);//add all files in that current folder.totalFilesList.AddRange(files);//Check if the current directory has sub-directories
string[] subDirs = Directory.GetDirectories(directory);//if yes, then call recursive functions..
if(subDirs.Length > 0)
{//now look for all files in current folder's sub-dir's.
foreach(string subDir in subDirs)
{
ArrayList tempArrayList = GetAllFiles(subDir);
totalFilesList.AddRange(tempArrayList);
}
}
return totalFilesList;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment