If I use fs.unlink to delete a locked file on Windows then the callback is called with an error, as expected. When I subsequently terminate node the file is deleted. I am at a loss as to how this might be happening and would prefer that locked files are not deleted. I should add that it is node that holds the lock so the file is presumably deleted when the lock is released.

有帮助吗?

解决方案

I never knew that Windows did this but apparently this is a feature of the DeleteFile SDK function. Not a lot that node can do about this.

其他提示

fs.unlinkSync('filename.extension');

will delete the file only if its unlocked. in case if the file is used it will give error

Resource is busy

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top