Most convenient way to edit a single string entry in a root file


I need to change the value of a string stored as a TObjString in a root file.

File structure:

- dir
    - valueInFile

My first idea was that this was a perfect use case for TBrowser, but it seems that this kind of editing is not possible. Manually editing the string through the root prompt (using valueInFile->String()(10) = 'x'; file->Write()) is also not possible, the updated value is not written to disk.

Is there a standard way doing a one-off edit of a single value in a TFile?


Sorry, but AFAIK, you can’t edit, but you can modify and save in another root file…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.


will only update the objects that are attached to the file, by default those are TTrees and Histograms. To store the TObjString you have to explicitly do so.

file->WriteObject( valueInFile );
1 Like