Answer the question
In order to leave comments, you need to log in
Forcefully delete a file in windows, is it possible with a couple of functions?
In general, a function works in Linux unlink(path);
for files that are locked by the system. In windows, the same function _unlink(path);
for locked files does not work. Is there an easy way to unlock files in use by the system with one/two standard winapi method calls?*
Answer the question
In order to leave comments, you need to log in
Yes and no. In Linux, deleting an open file is possible due to the architecture of the file system driver API.
In the window, this can only be done by killing the process that holds the file. Well, this is really done by calling a number of WinApi functions.
You don't understand how it works.
In Linux, the file system uses the iNode structure to store meta-information about files. And when you open a file, the iNode is searched for the file name, the file descriptor is attached and the iNode is already locked. In this case, the file name on the disk can be freely deleted (and the file data itself will be deleted later, when the process that opened the file descriptor releases it).
In the Windows file system, meta-information and the filename are stored together, and therefore an open file descriptor holds the name and cannot be deleted.
No undocumented function will change this behavior. Until the process that locked the file in Windows unlocks it, nothing will work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question