I create GENERIC_READ
file handle with createFile
.
This is my instruction :
hfile := CreateFileA(aFileName,
GENERIC_READ,
FILE_SHARE_READ or
FILE_SHARE_WRITE,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL or
FILE_FLAG_SEQUENTIAL_SCAN or
FILE_FLAG_OVERLAPPED,
0);
Now the problem is that when to process will read the file via hfile
sometime another process will need to "swap" the file, and to do this will need to rename it
this is how I do it :
MoveFileA(aFileName, aNewFileName);
But I have an error when I do this when their is still some file handle open. Is their any way to rename a file without first closing all it's GENERIC_READ file handle?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…