The process cannot access the file because it is being used by another process
Now that you know why the program cannot access the file, it is time to figure out which process has already put a lock on them. If the error is related to Windows Update and Photos App, look at the solution at the end of the post. To find out the lock, you will need to use Sysinternal Suite’s Process Explorer. Launch the Process Explorer program and locate the icon that says, “Find Windows Process.” Drag the icon, and drop it on the file, and it will instantly reveal the process. Please right-click on the process, and kill it. Now when you try to access the file with your program, it will not throw any error.
Windows Update Code 0x80070020
When updating or upgrading to Windows 10, if you get an error code 0x80070020, it means that files or resource required by the Windows Update process is being used elsewhere. The full error message says— The existing process cannot access the file because it is being used by another process. To fix this error, you will need to use the MSCONFIG tool to get the PC into a clean boot state and then try to update it again.
Photos App Error 0x80070020
A similar error happens with the Photos App as well, where it cannot save the file because another process is using it. You may have to change the file name or save it to another location, and so on. It’s not a critical error and only restricts from modification of files. The chances are that if you restart the computer, it will fix the problem, but if you face this all the time, these tips will help you resolve the problem. Read: How to tell which Process is locking a File?