Looping over folders and opening each folder to access the root file

Hi all,
I am new to root and wanted to ask basic question of accessing the root files. I would like to loop over the folders and then opening each folder and then open the root file inside these folders. Also, I am using root version 6.2.

So I am using TSystemDirectory for looping over the folders

TSystemDirectory dir("MyDir", "/path");
  auto files = dir.GetListOfFiles();
  for (auto fileObj : *files)  {
    auto file = (TSystemFile*) fileObj;
}

Thank you very much.

inside the loop you can do f = TFile(*iter)

RK

Dear RK,

I can’t able to get your comment. Can you explain little more?
I can already get the list of files from the above code but I want to open each of these folders and get the root file.