I am writing some events to a TFile. As I would like to know the size of the final file, just before closing it I am calling the GetSize() method on the TFile object but I am always getting a “cannot stat the file” error.
Why si this happening and how do I get the correct file size?
This is the final part of the code I am using (fTFileHandle is a TFile* object):
Please try getting the size of the file you are writing after you close it. This will ensure the contents are flushed to disk and you should not see the “cannot stat the file” error.
I can not reproduce the problem. Is the name of your file (on disk) really ‘FIle’ ?
Note that TFile::GetSize() always ask the *filesystem for the current set of the file on disk at that moment.
while TFile::GetEND() will tell you the size of the data that was save to the TFile but might have have been flushed to disk yet. In both case, calling after Close is the ‘right’ thing to do if you want to know the final size.