Niall Douglas wrote: ...
You can delete or rename open files on Windows just fine. It's just std::ofstream opens files in a way where you can't.
Another suggestion is that any decent Windows AV will not scan files incapable of holding executable code for binary viruses. std::ofstream opens files capable of holding executable code, so everything written to them must be scanned deeply. If you instead create a file without executability privileges, the AV should only scan for a small subset of potential malcontent.
Niall, your experience is deeply appreciated and your messages are very informative, but they would be even more useful if you actually say how things you describe are done. How should one open the file correctly so that it can be deleted and renamed while open, and has no executable privileges?