Saving TCanvas in a folder of a rootfile

Hi,

I can’t save a TCanvas at folders of rootfiles.
It’s wrong my code. How to change source?

[code]class Fittt {
public :
TCanvas* c1;
:
:
}
void Fittt::MakeRootfile(char *name,char *dirname){
TFile *f1 = new TFile(name,“UPDATE”);
TDirectory *dir = f1->GetDirectory(dirname);
if (!dir) f1->mkdir(dirname, fType);
f1->cd(dirname);

f1->WriteTObject(c1);

}[/code]

Folders is empty.

Regards,
YoungKwon

Replace your code by:

[code]void Fittt::MakeRootfile(char *name,char *dirname){
TFile *f1 = new TFile(name,“UPDATE”);
TDirectory *dir = f1->GetDirectory(dirname);
if (!dir) dir = f1->mkdir(dirname, fType);
f1->cd(dirname);

dir->WriteTObject(c1); 

}[/code]Rene

Thank you. :slight_smile:

regards,
YoungKwon.