Every guide lists its sources, tips, and warnings. Read our editorial policy.

Fixed: Error 0x80070020 When a File Is in Use by Another Program

Error 0x80070020 means the file you are copying, moving, or deleting is locked open by another process. Find the process with Resource Monitor or handle.exe, close it, and the action completes immediately.

The short answer

0x80070020 is ERROR_SHARING_VIOLATION. Open Resource Monitor, go to the CPU tab, search the Associated Handles box for the file name, and it tells you exactly which process is holding it. Close that process — or if it is Explorer itself, restart Explorer — then retry.

Download the full guide (PDF) Print checklist
Share
Set 52runoob as a preferred source on Google

You copy, move, or delete a file and Windows answers with `0x80070020: The process cannot access the file because it is being used by another process.` The file exists and the path is fine — something on your PC has it open right now, and until that grip is released, no other program can touch it.

Quick steps

  1. Note which file or folder the dialog names
  2. Search the file name in Resource Monitor's Associated Handles
  3. Close the process holding the handle
  4. Restart Explorer if the handle belongs to it
  5. Retry the copy, move, or delete
  6. Check antivirus and sync tools if the lock keeps returning

Things you'll need

  • The name of the file from the error dialog
  • Resource Monitor, built into Windows
  • An administrator account for ending system processes
  • handle.exe from Microsoft Sysinternals, optional but faster

Step-by-step

Method 1 of 3

Method 1 of 3: Find Out Who Is Holding the File

PDF
Step 1: Read the Dialog for the Exact File Name Download image

Step 1: Read the Dialog for the Exact File Name

The error names the file or folder it could not touch. Write it down, including the extension — `lock` messages on `notes.txt` and `notes.tmp` are different problems. If the dialog offers a Details expander, open it: sometimes Windows already tells you which program is responsible.

Step 2: Search Resource Monitor for the Handle Download image

Step 2: Search Resource Monitor for the Handle

Press Start, type `resmon`, and open Resource Monitor. On the CPU tab, click into the `Associated Handles` search box and type the file name. The list underneath shows every process with a live handle on it, with its PID. That is your answer — no guessing about which app to close.

Step 3: Use handle.exe for a Faster Answer Download image

Step 3: Use handle.exe for a Faster Answer

Microsoft's Sysinternals `handle.exe` does the same search from a terminal, in seconds: `handle.exe "notes.txt"` lists the process and PID holding the file. On a file you touch often, keep handle.exe on the desktop — one command replaces the entire Resource Monitor workflow.

Step 4: Check Whether Explorer Itself Is the Holder Download image

Step 4: Check Whether Explorer Itself Is the Holder

If the process in the results is `explorer.exe`, the preview pane or a thumbnail scan has the file open. This is the most common holder and the most harmless: the file is not in use by anything you opened, just by Windows drawing its own folder view.

Step 5: Look for Sync and Backup Tools in the List Download image

Step 5: Look for Sync and Backup Tools in the List

OneDrive, Google Drive, Dropbox, and backup agents all hold brief handles while they upload a file you just saved. If the holder is one of these, the lock releases by itself within seconds. Pause the sync client if you need the file right now, or simply retry the copy.

Method 2 of 3

Method 2 of 3: Release the File

PDF
Step 6: Close the Holding Process Normally Download image

Step 6: Close the Holding Process Normally

If Resource Monitor names an app you recognize — Word holding a document, Excel holding a spreadsheet — switch to that app and close the file inside it, or close the app itself. A clean close releases the handle and flushes any unsaved changes, which a force-kill would lose.

Step 7: End the Process in Task Manager Download image

Step 7: End the Process in Task Manager

When the holder will not close on its own, press `Ctrl+Shift+Esc`, find it under Processes, right-click, and choose `End task`. Use this on apps you have already tried to close normally. If the handle was the only thing it held, the file is free the moment the process exits.

Step 8: Restart Windows Explorer Download image

Step 8: Restart Windows Explorer

For an Explorer-owned handle, right-click `Windows Explorer` in Task Manager and choose Restart. The screen flashes and every folder window closes — no files are lost, but the preview and thumbnail handles are dropped. Retry your copy immediately after the desktop comes back.

Step 9: Sign Out to Release Every Handle at Once Download image

Step 9: Sign Out to Release Every Handle at Once

If the file is held by something you cannot identify, sign out of Windows instead of shutting down apps one by one. Signing out closes every process in your session, releasing every handle. Sign back in and retry before anything reopens the file.

Step 10: Retry the Original Action Download image

Step 10: Retry the Original Action

With the handle released, run the copy, move, or delete again. If the error is gone, you are done. If it comes back immediately with the same file, something re-opens it the moment it is freed — that is a background tool, and Method 3 is where you stop it.

Method 3 of 3

Method 3 of 3: Stop the Lock From Coming Back

PDF
Step 11: Pause the Sync Client Before Big Moves Download image

Step 11: Pause the Sync Client Before Big Moves

OneDrive and similar tools re-grab any file that changes under their watched folders. Before reorganizing a synced folder, click the cloud icon in the tray and pause syncing for an hour. Do the moves with the client asleep, then resume and let it upload the new layout.

Step 12: Exclude the Folder From Antivirus Scanning Download image

Step 12: Exclude the Folder From Antivirus Scanning

Real-time scanners hold files open while checking them, and a busy folder — a build output, a photo import — hits 0x80070020 constantly. Add that folder to your antivirus exclusion list so it is not scanned on every write. Keep the exclusion narrow: one work folder, not the whole drive.

Step 13: Turn Off the Preview Pane Download image

Step 13: Turn Off the Preview Pane

Explorer's preview pane opens every file you click, and on large documents its handle outlives your click. Press `Alt+V` in File Explorer and untick Preview pane, or uncheck it under `View > Preview pane`. The 0x80070020 errors that came from Explorer stop appearing.

Step 14: Disable Thumbnail Generation for Problem Folders Download image

Step 14: Disable Thumbnail Generation for Problem Folders

Thumbnails are built by opening the file, so a folder of raw photos or videos locks constantly. Open `Folder Options > View` and tick `Always show icons, never thumbnails`. On media folders you copy often, this removes the most frequent Explorer handle entirely.

Step 15: Run the Copy With Robocopy Retry Settings Download image

Step 15: Run the Copy With Robocopy Retry Settings

For big moves where one locked file should not kill the job, use robocopy: `robocopy "C:\From" "D:\To" /E /R:2 /W:5`. The `/R:2 /W:5` retries a locked file twice with a five-second wait — long enough for a sync tool to release it — and the summary lists whatever stayed locked so you can handle it individually.

Tips

  • 0x80070020 is not corruption. The file is fine — it is just open somewhere. Find the holder before assuming damage.
  • Resource Monitor's handle search is the built-in answer. handle.exe is the fast one. Everything else is guessing.
  • A lock that returns within seconds of being released is a background tool, not an app you opened.
  • Restarting Explorer is safe and instant. Make it your first move whenever the holder is explorer.exe.

Warnings

  • Do not force-kill a process that is writing the file — you can leave it half-written and corrupted. Close it normally first.
  • Antivirus exclusions reduce protection for that folder. Exclude one work folder, never the whole drive or Downloads.
  • Ending a system process to release a handle can destabilize the session. Sign out instead if the process looks system-level.
  • Do not use third-party unlocker tools that promise to force-release handles — the built-in tools do this safely already.

Frequently asked questions

Why does the file say it is in use when nothing is open?

Because something invisible has it open: the Explorer preview pane, a thumbnail scan, a sync client uploading your last save, or an antivirus real-time scan. Resource Monitor's Associated Handles search names the actual holder in seconds.

Is it safe to end the process holding my file?

If the process is just reading the file, yes. If it is writing — a save in progress, a sync upload — a force-kill can corrupt it. Close the app normally first and reserve End task for processes that refuse to close.

Why does this happen most with my OneDrive folder?

OneDrive holds a handle while uploading, and reorganizing a synced folder makes it touch every file. Pause syncing before big moves and resume afterwards. The files were never damaged — they were mid-upload.

Can I copy a file while it is locked?

Reading is usually fine even when a file is open; writing and deleting are what 0x80070020 blocks. Robocopy with /R:2 /W:5 waits for the lock to drop. If the holder never releases, restart it or sign out first.

References

  1. Microsoft Learn — System Error Codes 0–499 (0x80070020, ERROR_SHARING_VIOLATION). https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
  2. Microsoft Sysinternals — Handle. https://learn.microsoft.com/en-us/sysinternals/downloads/handle
  3. Microsoft Learn — robocopy command reference. https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy
  4. Microsoft Support — Save disk space with OneDrive Files On-Demand. https://support.microsoft.com/en-us/office/save-disk-space-with-onedrive-files-on-demand-0e6860d3-d9f3-4971-b321-7092438fb38e
  5. Microsoft Learn — Resource Monitor overview. https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/resource-monitor

Every guide is reviewed against its sources. See our editorial policy.

Get one fix like this every week

One short email with the most useful new guide and a printable checklist. No spam, unsubscribe anytime.

Reader comments

0 so far

Finished this guide? Tell other readers what worked, what didn't, and what you would change.

Stuck on a step? Tell us your device model and what happened — an editor reads every comment and usually replies within 48 hours.

Be kind and constructive. Comments are published instantly.