Hello, Philippe!
Seems, like this solution does not work for me.
I attached the simple root file with “:” in the name of TDirectory.
I’ve tried to go inside this TDirectory by this code:
#include <iostream>
#include <TFile.h>
#include <TKey.h>
#include <TROOT.h>
int main() {
using namespace std;
TFile *f_input = new TFile("Tdir.root");
TIter next(f_input->GetListOfKeys());
TKey *key;
while ((key= (TKey*)next())) {
cout<<"I'm in this dir: "<<gDirectory->GetName()<<endl;
cout<<"Trying to go to : "<<key->GetName()<<endl;
TDirectory* subdir = (TDirectory*)gDirectory->FindObject(key->GetName());
if (subdir) subdir->cd();
cout<<"Now I'm in this dir: "<<gDirectory->GetName()<<endl;
}
f_input->Close();
return 1;
}
The result is:
I'm in this dir: Tdir.root
Trying to go to : Top::folder
Now I'm in this dir: Tdir.root
Am I doing something wrong?
Best regards, Iurii
Tdir.root (1.3 KB)