Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open file in Windows while not blocking its renaming

Tags:

file

windows

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?

like image 429
Viliam Avatar asked Aug 11 '09 15:08

Viliam


People also ask

Can you rename a file while it is open?

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.

Can't be completed because the file is open in system?

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.

Why can't I change the name of a file?

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.


1 Answers

You need to open your file with the sharing mode FILE_SHARE_DELETE (0x00000004).

See MSDN help for the CreateFile API.

like image 133
cedrou Avatar answered Sep 19 '22 06:09

cedrou