This is a discussion on File operation (rename,remove,fopen) fail on Windows XP - Programmer ; Hi I've developed a logging application, which provides rotation of log files after creating a fixed number of backups of the actual log file. The module involves extensive file operations. It identifies the next backup candidate that shall be removed, ...
I've developed a logging application, which provides rotation of log files
after creating a fixed number of backups of the actual log file. The module
involves extensive file operations. It identifies the next backup candidate
that shall be removed, and in whose name the actual log file will be
renamed. This way, a new backup is taken for the actual log file after it
reaches its max-specified size.
Currently, the remove() operation and rename() and fopen() operations are
performed almost once every minute i.e the actual log file is closed, the
target backup file is removed, the actual is renamed to the target backup
file and the actual log file is opened in append mode once every minute.
The application runs fine for almost 24 hours but after that suddenly the
removal of the target backup file fails stating the error as Access denied,
even though the backup file does not have read only permissions and neither
is the file in an open state.
Once the remove() fails, the rename() also fails stating that the
destination file already exists. After rename() fails, the fopen() on the
actual log file, which we closed prior to performing remove and rename, also
fails to get opened in an append mode.
Its strange that the logging application comes in this state after executing
the same code for more that 24 hours. Is there some limitation of the
Windows XP OS on file operations that we are unaware of?
Note: The OS is windows XP Sp1 without Advanced Networking Pack.
If there is any information on the same please write to me at