rename of file

Hi,

I've opened a file using open();

now after writing few lines i need to take a backup without closing the handle.

How to do that?

Basically I've a file where the handle is open but I want to rename the file without closing the handle.

I'm able to rename in unix but when it comes to Windows I'm not able to.

Kindly help me how to achive this.

Regards
Vijay
Try to use FILE_SHARE_DELETE as argument to CreateFile() when you open the file.
when i try to rename I'm getting an error number as 32. Means file is used by another process. In that case also is it possbile to rename the file???
You would use CreateFile() if you just want to rename a file, I see that you are actually trying to make a backup. In this case use CopyFile(), the new name will be the second argument to the function. If you are trying to delete a file you need to have all of the references to it destroyed, this may not be your application though it could be your antivirus running a scan in the background.
Actually this is my real scenario

1. open a file
2. write the info to the file
3. if it reaches a max size, rename the opened file
4. if the count of the rename file reaches 5 then delete the old backup file

in Unix,

I'm doing unlink and rename.
but in windows same is not happening.

Also when my system is running, in Unix I can delete the log files manually where as in win I'm not able to delete manually.

I've used only open function to create a file and get the handle.

When i try to Unlink or rename a file it is giving me error number 32(used by another process). I want to forcefully rename or delete even multiple process is using the file.

Now kindly tell me how to achive the same behaviour in win.
Topic archived. No new replies allowed.