My simple example was to copy all the keys from a directory, excluding subdirs. A bit more complex logic is required to navigate in the directory tree. The best solution would be a TDirectory::CopyDir or like function. This will be implemented one day, but not in the coming weeks. Rene Brun Markus Stoye wrote: > > Hi, > Trying your suggestion the last Line ( ..->Write()) actually returned > Int 0 and did not write? > The copied File consits of several further Directories. > > Rene Brun wrote: > > > Hi Markus, > > > > There is no direct function to do this. However, you can do > > something like: > > > > TFile f("30200020026938.root"); > > f.cd("Record3"); > > TDirectory *old = gDirectory; > > old->ReadAll(); > > TFile f2("newfile.root","recreate"); > > f2.mkdir("subdir"); > > f2.cd("subdir"); > > old->GetList()->Write(); > > > > > > Rene Brun > > > > Markus Stoye wrote: > > > > > > Hi' > > > I've got a TFile with several TDirectories: > > > > > > root [0] TFile f("30200020026938.root") > > > root [1] f.ls() > > > TFile** 30200020026938.root > > > TFile* 30200020026938.root > > > KEY: TDirectory Record2;1 Record2 > > > KEY: TDirectory Record3;1 Record3 > > > KEY: TDirectory Record4;1 Record4 > > > KEY: TDirectory Record1;1 Record1 > > > > > > and wand to copy and rename one Directory into another TFile.
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET