I recently had a situation where a program had a file or a folder locked and I had no idea what program that might be!

I needed to restore a folder from a Macrium backup but I didn't want to just overwrite the folder, so I wanted to rename it.  But I wasn't able to do that because some processes had a folder or file locked in there.

After some search, I found an answer that didn't need any additional software to be installed, but rather use a tool that has been in Windows for several versions.  The Resource Monitor!  The answer can be found on Superuser.com

Run the Resource Monitor, then go to the CPU tab, and expand the "Associated Handles" panel - see the screenshot below.

Click the checkbox next to "Image" at the top of the "Processes" list and it will select all the processes in the list.

The "Associated Handles" will then fill in - it can take a few moments if there are a lot of processes running.

You can then sort and filter the list to narrow it down to what you are looking for, see the screenshot below.

Here I have filtered it to show "C:\" so it will show any files on the C:\ drive that are locked.  I also sorted it by the "Handle Name" so it is easy to find based on the path.

You can also find services, sessions, registry keys etc., so this is a very easy way to find things.  For more powerful options, using Processs Explorer from SysInternals/Microsoft has more options and is also 100% free and certainly an excellent tool along with Process Monitor.