Hi, this is a newbie question: I have some root files inside a directory, how can I get a list of all of them to read them one by one?
Thanks
Hi,
Here is a simple example:
[code]#include “Riostream.h”
#include “TSystemDirectory.h”
#include “TList.h”
#include “TString.h”
void ls_root()
{
TSystemDirectory dir(".", “.”);
TList *files = dir.GetListOfFiles();
if (files) {
TIter next(files);
TSystemFile file;
TString fname;
while ((file=(TSystemFile)next())) {
fname = file->GetName();
if (fname.EndsWith(".root")) { // it is a root file
cout << "Found " << fname.Data() << “…” << endl;
// do whatever you want with the file…
}
}
delete files;
}
}[/code]
Cheers, Bertrand.
Thankk you very much, bellenot!