Exact opposite of this question.

I'm trying to track an intermittent issue with a software, issue that seems to be related to a folder that is kept locked for just a bit too long... once in a while.

I want to find a way to lock it myself and choose when the lock is to be released. How can I achieve that?

I know of at least one software that can lock a file, but for the next step, I need to find a way to lock an empty folder.

  • Perhaps useful link: How to Lock Folder in C#. If you have at least some programming experience you should be able to copy and paste this into visual studio and build the executable. Aug 7, 2018 at 18:07
  • @BennettYeo: Thanks. I hadn't seen that before. It'd definitely work, but I'm hoping for a lighter solution. But you make me realize that I could possibly find something in powershell. I'll have to look.
    – jmr
    Aug 7, 2018 at 18:45
  • Jmr if you want a powershell script try this: Locking the file while writing in PowerShell. It will be harder to customize than the C# script. Aug 7, 2018 at 18:47
  • @BennettYeo: Thanks again. I got it to work for locking files, but not for folders. The error is a bit strange (access denied), but given that the (working) file and (not working) folders are in the same place, I'm more suspecting that that API doesn't make sense when called on folders - especially given its name.
    – jmr
    Aug 7, 2018 at 19:32
  • Duty Check: Are you running elevated? Sometimes access denied errors can be fixed if you run as admin. Aug 7, 2018 at 19:34

1 Answer 1


We can set the "Delete" and "Delete subfolders and files" permissions to "Deny" under PropertiesSecurityAdvanced.

Change the Type to “Deny” and first make sure not any other permission is selected, we can click the “Clear all” button to do that. Now only tick the “Delete subfolders and files” and “Delete“.

enter image description here

For details, we can refer this articles: https://quickfever.com/how-to-lock-folders-or-files-to-prevent-deletion-981593/

  • Thanks. This is a similar approach to what was suggested in the chat - change the folder permissions rather than block the folder as "currently in use", but it might very well work. I'll have to try and report back.
    – jmr
    Aug 9, 2018 at 2:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.