How do we judge whether a file that is being opened has been forgotten to close or is being used?
If another user is using it, it does not seem appropriate to force it to be turned off.
However, if you really want to do this, you might consider using Process.Kill().
Just be aware that this method will not be available if the program is placed in the user's local machine instead of the Windows server, because this method can only work on processes running on the local computer.
Please also refer to the following link, which may help you.
Force close an open network file on Windows Server 2012 with C#
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.