Get rid of TH2 Projections in TFile

I need to store in a TFile a TH2F and before I write it on I use the ProjectionX to make some calculations. I’d like not to write all the TH1D projections, which I suppose are generated when I call the ProjectionX method.
How can I do it?
Many thanks in advance,
E.

Hi,
you can call

TH1*projx=h2->ProjectionX(…);
projx->SetDirectory(0);

Axel.