Automatic file deletion on closure

This topic describes how a temporary file can be destroyed automatically when the owning thread closes it or if the owning thread crashes.

Set EDeleteOnClose when opening a temporary file to enable the automatic deletion on closure. EDeleteOnClose can be used with RFile::Temp() and RFile::Create() . For example:

      
       
      
      r = file.Create(TheFs, filename, EFileShareAny | EFileRead | EFileWrite | EDeleteOnClose);
     

The purpose of this flag is to prevent memory leaks when components that create temporary files crash.

Note:
  • Existing files cannot be opened with EDeleteOnClose set. Any attempts to do this will return the error message KErrArgument .

  • Automatic file deletion is not default behavior.