Chandrayya G K
Chandrayya G K

Reputation: 8849

Recursively list all files in eclipse workspace programmatically

I am getting workspace by calling ResourcesPlugin.getWorkspace().getRoot().

How I can list all files(IFile) recursively in the workspace.

Upvotes: 4

Views: 3220

Answers (1)

greg-449
greg-449

Reputation: 111217

The root, projects and folders in a workspace all implement the IContainer interface.

Call IContainer.members() to get all the resources in the container.

Something like:

void processContainer(IContainer container) throws CoreException
{
   IResource [] members = container.members();
   for (IResource member : members)
    {
       if (member instanceof IContainer)
         processContainer((IContainer)member);
       else if (member instanceof IFile)
         processFile((IFile)member);
    }
} 

Upvotes: 9

Related Questions