I have a piece of code that renames a file from A.ACK.tmp to A.ACK in the same directory (C:\abc). Meanwhile there is another process that polls C:\abc, looking for files with a .ACK extension. Once it sees such a file, it moves it to folder D:\ABC.
To rename the file I do the following
if ( !::MoveFileEx(tmpRnFile, RenamedFileName,
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) )
{
LogEvent(EVMSG_SENT_FAILED, tmpRnFile, RenamedFileName, GetLastErrorString() );
return EVMSG_SENT_FAILED;
}
Where tmpRnFile = C:\abc\A.ACK.tmp and RenamedFileName = c:\abc\A.ACK
The problem I have is that MoveFileEx returns a nonzero value - GetLastError returns 0x2: The system cannot find the file specified.
Please can anyone help? How does a move process work in NT, and can another process move or delete a file during the rename process?
What other rename method can I use to ensure that I dont get this problem.
Thanks
Milton
To rename the file I do the following
if ( !::MoveFileEx(tmpRnFile, RenamedFileName,
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) )
{
LogEvent(EVMSG_SENT_FAILED, tmpRnFile, RenamedFileName, GetLastErrorString() );
return EVMSG_SENT_FAILED;
}
Where tmpRnFile = C:\abc\A.ACK.tmp and RenamedFileName = c:\abc\A.ACK
The problem I have is that MoveFileEx returns a nonzero value - GetLastError returns 0x2: The system cannot find the file specified.
Please can anyone help? How does a move process work in NT, and can another process move or delete a file during the rename process?
What other rename method can I use to ensure that I dont get this problem.
Thanks
Milton