有时,在您的Windows(r)计算机( Windows computer)上删除文件时(deleting a file on you),您可能会遇到“无法完成操作,因为该文件已在程序中打开(The action can’t be completed because the file is open in a program)”的错误消息。当这个错误弹出时,这意味着你正在处理一个锁定的文件,无论你做什么都不能删除你的文件。您的 PC 将继续在屏幕上抛出相同的错误,让您知道该文件正在某个程序中使用。
处理此类锁定的文件错误实际上很容易,尽管最初可能看起来并不那么容易。您现在可能已经猜到您无法删除文件的原因是因为您 PC 上的应用程序正在使用它。你继续关闭那个程序,然后删除文件怎么样?
有几种类似的解决方法可以帮助您成功删除计算机上的锁定文件。
关闭正在使用锁定文件的程序(Close The Program That Is Using The Locked File)
最明显的解决方案是关闭正在使用您要删除的文件的程序。如果是在MS Word中打开的Word文件,请关闭程序,您就可以删除锁定的文件。
同样,无论文件在哪个程序中打开,只需关闭该程序,它就会释放准备删除的文件。
使用任务管理器终止程序进程(Kill The Program Process Using Task Manager)
有时会发生使用锁定文件的程序不会响应您的操作而只是停留在某个点的情况。如果您遇到这种情况,您可能需要终止该程序的进程,以便在您的计算机上强制关闭它。
程序关闭后,您的文件应该没有任何进程,您可以将其从计算机中删除。
- 右键单击(Right-click)屏幕底部的任务栏,然后选择任务管理器(Task Manager)选项。它将在您的计算机上启动该实用程序。
- 如果您在打开时没有立即看到所有进程,请单击“更多详细信息(More details)”选项以展开视图。
- 如果您还没有,请单击顶部的“进程”选项卡。(Processes)您应该看到当前在您的计算机上运行的所有进程。您想找到您认为正在使用您的文件的进程。然后单击进程以选择它,然后单击右下角的结束任务(End task)按钮。
- 它将结束您选择的程序的过程,您现在应该能够删除 PC 上的文件。
关闭文件资源管理器中的预览窗格(Turn Off The Preview Pane In File Explorer)
文件资源管理器(File Explorer)中的预览(Preview)窗格可让您查看锁定文件的预览。可能是您的文件正在预览中使用,这就是阻止您在Windows机器上删除它的原因。
禁用窗格应该可以为您解决问题。
- 在您的 PC 上启动文件资源管理器。(File Explorer)打开屏幕上的任何文件夹都应该为您执行此操作。
- 打开后,找到并单击顶部的“查看”选项卡。(View)您正在寻找的选项位于那里。
- 查看显示Panes的第一个窗格,您会发现一个选项Preview pane。单击(Click)它,如果之前启用它,它将被禁用。
如果“预览(Preview)”窗格已占用该文件,您应该可以删除该文件。
在文件资源管理器中切换文件夹进程(Toggle The Folder Process In File Explorer)
文件资源管理器(File Explorer)进程可能正在使用您锁定的文件,因此您无法删除它。实际上有一个选项可以帮助您为您在 PC 上打开的每个文件夹创建单独的进程,值得切换它以查看它是否有助于解决您的问题。
- 打开文件资源管理器(File Explorer)并访问查看(View)选项卡。单击(Click)选项(Options)选项下方的向下箭头,然后选择更改文件夹和搜索选项(Change folder and search options)。
- 单击以下屏幕上的查看选项卡。(View)
- 您会发现几个可以为文件资源管理器(File Explorer)实用程序启用和禁用的选项。在单独的进程中(Launch folder windows in a separate process)找到读取启动文件夹窗口的选项并启用它。如果该选项已启用,则应禁用它。
- 单击应用(Apply),然后单击确定(OK)以保存更改。
启动并关闭锁定的文件(Launch & Close The Locked File)
可能是您上次在程序中访问锁定的文件时没有正确关闭它。
- 可以肯定的是,只需在程序中打开文件,然后正确关闭它。
- 文件完全关闭后,右键单击它并选择Delete。该文件将被删除,而不会在您的屏幕上引发任何错误。
重新启动 Windows 计算机(Restart Your Windows Computer)
重新启动您的机器会关闭所有进程,这包括正在使用您的文件的进程。
- 单击开始菜单(Start Menu),选择电源图标,然后选择重新启动(Restart)。
使用命令提示符删除文件(Use Command Prompt To Delete The File)
您可以尝试使用命令提示(Command Prompt)实用程序删除图形用户界面中无法删除的文件。
- 同时按Windows + R键,输入cmd,然后按 Enter(Enter)。
- 键入以下命令,然后按Enter。确保将PATH替换为要删除的文件的路径。
删除路径(del PATH)
它会立即删除文件而不会出现任何错误。
使用第三方应用程序解锁和删除文件(Use A Third-Party App To Unlock & Delete The File)
出于某种原因,如果上述方法都不适合您,您可能需要使用第三方应用程序来解锁文件(use a third-party app to unlock the file),然后将其删除。
Unlocker是一款免费应用程序,可帮助您解锁文件,以便您随后删除它们。
- 在您的 PC 上下载(Download)、安装和启动该应用程序。
- 它会要求您选择文件。选择您无法删除的文件,然后单击OK。
它会执行解锁文件所需的操作,然后在没有任何提示的情况下将其从计算机中删除。
How to Open a Locked File When Another Program Is Using It
Sometimeѕ while deleting a file on your Windows computer, you may come across an error that says “The action can’t be completed because the file is open in a program”. When this error pops-up, it means you’re dealing with a locked file and you can’t delete your file no matter what you do. Your PC will keep on throwing the same error on your screen letting you know the file is in use in some program.
Dealing with such locked file errors is actually pretty easy, although it may not seem so initially. You’ve probably guessed by now that the reason you aren’t able to delete the file is because an app on your PC is using it. How about you go ahead and close that program, and then delete the file?
There are several workarounds like this to help you successfully delete the locked file on your computer.
Close The Program That Is Using The Locked File
The most obvious solution is to close the program that’s using the file you want to delete. If it’s a Word file open in MS Word, close the program and you’ll be able to delete the locked file.
Similarly, whatever program the file is open in, simply close the program and it’ll free-up the file ready to be deleted.
Kill The Program Process Using Task Manager
It sometimes happens that the program that uses the locked file doesn’t respond to your actions and just stays stuck at some point. If this is the case with you, you might want to kill the process for the program so it can be forcibly closed on your computer.
Once the program is closed, your file should be free from any processes and you’ll be able to remove it from your machine.
- Right-click on the taskbar located at the bottom of your screen and select the Task Manager option. It’ll launch the utility on your computer.
- If you don’t see all your processes right away when it opens, click on the More details option to expand the view.
- Click on the Processes tab at the top if you aren’t already there. You should see all the processes that are currently running on your computer. You want to find the process that you think is using your file. Then click on the process to select it and then click on the End task button at the bottom-right corner.
- It’ll end the process for your selected program and you should now be able to delete the file on your PC.
Turn Off The Preview Pane In File Explorer
The Preview pane in File Explorer lets you see the previews of your locked file. It may be your file is being used in the preview and that’s what’s preventing you from deleting it on your Windows machine.
Disabling the pane should fix the issue for you.
- Launch File Explorer on your PC. Opening any folder on your screen should do this for you.
- When it opens, find and click on the View tab at the top. The option you’re looking for is located there.
- Look towards the first pane that says Panes and you’ll find an option saying Preview pane. Click on it and it’ll be disabled if it was enabled before.
You should be able to delete the file if Preview pane had occupied it.
Toggle The Folder Process In File Explorer
It’s possible that a File Explorer process is using your locked file and so you are unable to delete it. There’s actually an option that helps you create separate processes for each folder you open on your PC and it’s worth toggling it to see if it helps resolve your issue.
- Open File Explorer and access the View tab. Click on the down-arrow beneath the Options option and select Change folder and search options.
- Click on the View tab on the following screen.
- You’ll find several options that you can enable and disable for the File Explorer utility. Find the option that reads Launch folder windows in a separate process and enable it. If the option is already enabled, you should disable it.
- Click on Apply followed by OK to save the changes.
Launch & Close The Locked File
It could be the locked file wasn’t closed properly the last time you accessed it in your programs.
- To be sure, just open the file in your program and then close it properly.
- When the file is fully closed, right-click on it and select Delete. The file will delete without throwing any errors on your screen.
Restart Your Windows Computer
Rebooting your machine closes all the processes and this includes the one that’s using your file.
- Click on the Start Menu, select the power icon, and choose Restart.
- Try deleting the file when your computer reboots.
Use Command Prompt To Delete The File
You can try using the Command Prompt utility to delete the file that can’t be deleted in graphical user interface.
- Press the Windows + R keys at the same time, type in cmd, and hit Enter.
- Type in the following command and press Enter. Make sure to replace PATH with the path of the file you want to delete.
del PATH
It’ll delete the file straightaway without any errors.
Use A Third-Party App To Unlock & Delete The File
For some reason, if none of the above methods work for you, you might want to use a third-party app to unlock the file and then delete it.
Unlocker is a free app that helps you unlock your files so you can then delete them.
- Download, install, and launch the app on your PC.
- It’ll ask you to select your file. Choose the file that you’re unable to delete and click on OK.
- Select Delete from the first dropdown menu and click on OK.
It’ll do what it needs to do to unlock your file and then get it deleted from your computer without any prompts.