# Read in files in a dictionary

**URL:** <https://root-forum.cern.ch/t/read-in-files-in-a-dictionary/33180>\
**Category:** Newbie\
**Created:** [March 15, 2019, 12:57pm UTC](https://root-forum.cern.ch/t/read-in-files-in-a-dictionary/33180 "2019-03-15T12:57:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hampus\_Hahne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/e95f7d/32.png) [@Hampus\_Hahne](https://root-forum.cern.ch/u/Hampus_Hahne)\
**Post date:** [March 15, 2019, 12:57pm UTC](https://root-forum.cern.ch/t/read-in-files-in-a-dictionary/33180/1 "2019-03-15T12:57:26Z")

</div>

Hello !

I want to use the TFile command to read in root files. Since my project contains loads of files so to be more structured, i have created dictionaries. It is something in this way

Tfile \*file1 = new TFile( "\banks\myfile.root " , “READ” )

So the file is under directionary banks and the file in questions is myfile.root. The C-file (where im coding) is in the same dictionary as the banks dictionary.

How do i put in dictionaries in the TFile command ?

kind regards  
Hampus

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [March 18, 2019, 8:16am UTC](https://root-forum.cern.ch/t/read-in-files-in-a-dictionary/33180/2 "2019-03-18T08:16:13Z")

</div>

I suppose you mean “directories” and not dictionaries, right? So you can simply specify the directories in the [`TFile::Open()`](https://root.cern.ch/doc/master/classTFile.html#aec5f3fae0774aabfc615ebb4b00fe5e0) method:

```auto
   auto file1 = TFile::Open("./banks/myfile.root", "READ");

```

or, if your C macro is in the same directory than the root file:

```auto
   auto file1 = TFile::Open("myfile.root", "READ");

```

---

<div class="post-metadata">

**Author:** ![Hampus\_Hahne](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/e95f7d/32.png) [@Hampus\_Hahne](https://root-forum.cern.ch/u/Hampus_Hahne)\
**Post date:** [March 18, 2019, 12:25pm UTC](https://root-forum.cern.ch/t/read-in-files-in-a-dictionary/33180/3 "2019-03-18T12:25:08Z")

</div>

Yes of course! Sorry for the misspelling. Gonna try it out now 🙂
