Build a list of rootfile from directory

Hi all,
I have several rootfiles each with several histograms to fit.
For each file I am able to loop inside it, get the histogram and fit it, but I would like to write a piece of code to build a list (or whatever) that has all the files I have in my directory.
So I could loop over this list and for each file loop over the histograms.

I have tried gSystem->Exec(“ls *.root”) but I don’t know how to grab the output to build a proper list.

Can anybody send me an hint?

Thank you!

see an example in tutorial importCode.C. If you do not have it in your distribution, it is in the attachement.

Rene
importCode.C (2 KB)

Thank you Rene! It worked fine!