Is there a way to keep a file open, while not blocking its renaming by another application?
Keeping the file open does not block its renaming in Unix. Can I achieve the same behavior in Windows?
It depends on the operating system. In UNIX and similar systems (OS X and Linux) you can rename an open file. Files are numbered by the file system and the file names (which themselves are held in files, one per folder) just reference the file numbers.
If the error message “the action cannot be completed because the file is open in the system” still bothers you, you can try emptying the trash. This is the simplest action, according to users, that might solve your problem. So, find the trash can on your desktop, right-click it and select Empty Trash.
When a file or folder is still open, Windows doesn't allow users to rename it. Therefore, you must ensure that no files or folders are open and no apps are running in the background while you're renaming. To do that, simply click on the same file again to open it, and it will take you to the already opened tab.
You need to open your file with the sharing mode FILE_SHARE_DELETE
(0x00000004).
See MSDN help for the CreateFile API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With