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(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;
}
World of tricky Core Java Q and A Covering Object Oriented Analysis and Design, JVM Internals,Java Language Fundamentals,Datatypes,Keywords,Operators and Assignments,Identifies,Declarations and Modifiers, Conversion,Casting and Promotion, Flow control,Assertions, Exception Handling and Garbage Collection,Objects and Classes), Basic Packages and their classes,JDBC,JFC Swing,Java Server Pages (JSP), Servlets,EJB,JMS,JNDI etc and Open source technologies like Struts,Hibernate,Spring etc
Search This Blog
Saturday, May 17, 2008
A simple recursive function to get all files in all sub-dirs of a folder
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment