Delete any file windows

File. Delete(String) Метод

Определение

Удаляет указанный файл. Deletes the specified file.

Параметры

Имя файла, предназначенного для удаления. The name of the file to be deleted. Подстановочные знаки не поддерживаются. Wildcard characters are not supported.

Исключения

path представляет собой строку нулевой длины, содержащую только пробелы или один или несколько недопустимых символов, заданных методом InvalidPathChars. path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.

path имеет значение null . path is null .

Указан недопустимый путь (например, он ведет на несопоставленный диск). The specified path is invalid (for example, it is on an unmapped drive).

Указанный файл используется. The specified file is in use.

-или- -or- Для файла имеется открытый дескриптор, а операционной системой является Windows XP или более ранней версии. There is an open handle on the file, and the operating system is Windows XP or earlier. Этот открытый дескриптор может быть результатом перечисления каталогов и файлов. This open handle can result from enumerating directories and files. Дополнительные сведения см. в разделе Практическое руководство. Перечисление каталогов и файлов. For more information, see How to: Enumerate Directories and Files.

Параметр path задан в недопустимом формате. path is in an invalid format.

Указанный путь, имя файла или оба значения превышают максимальную длину, заданную в системе. The specified path, file name, or both exceed the system-defined maximum length.

У вызывающего объекта отсутствует необходимое разрешение. The caller does not have the required permission.

-или- -or- Файл является исполняемым файлом, который уже используется. The file is an executable file that is in use.

-или- -or- path является каталогом. path is a directory.

-или- -or- Параметр path указывает файл только для чтения. path specified a read-only file.

Примеры

В следующем примере группы файлов копируются в папку резервного копирования C:\archives\2008, а затем удаляются из исходной папки. The following example copies groups of files to the C:\archives\2008 backup folder and then deletes them from the source folder.

Комментарии

Укажите имя файла с любыми относительными или абсолютными путями для path параметра. Specify a file name with any relative or absolute path information for the path parameter. Подстановочные знаки не могут быть добавлены. Wildcard characters cannot be included. Сведения об относительном пути интерпретируется как относительно текущего рабочего каталога. Relative path information is interpreted as relative to the current working directory. Сведения о получении текущего рабочего каталога см. в разделе GetCurrentDirectory . To obtain the current working directory, see GetCurrentDirectory.

Читайте также:  Linux логин без пароля

Если удаляемый файл не существует, исключение не создается. If the file to be deleted does not exist, no exception is thrown.

Список общих задач ввода-вывода см. в разделе Общие задачи ввода-вывода. For a list of common I/O tasks, see Common I/O Tasks.

How to Delete Files on Win­dows 10 That Insist on Staying

Chaitanya Tapase

15 Oct 2015

Windows can’t seem to shake its legacy off. After evolving to a point which looks very modern and nothing like the comical Windows XP or the super stoic Windows 7, there are still some things that won’t leave Windows 10 alone. Corrupt files being only one of them.

Don’t bang your keyboard if you can’t delete a file

I’ve already seen a few users facing an error message while deleting unwanted files on their systems. Files that insist that they are ‘In Use’ when clearly nothing is open on the users system. How can you get rid of such undeletable files? No need to google, we are here to make your life easier.

1. Try Killing the Task

I spoke about Window’s legacy for a reason. Sure, it has its cons, but it’s got it pros too. One great thing that I’ve always liked about Windows is the great Task Manager. This not only gives you an idea of running apps and services at any time on your computer, you can also use it to kill services that might be stopping you from deleting certain files.

So, for example, if you can recognize the type of file yourself (say Excel), then hunt for the locked file or process in the Task Manager window and right-click on it. Then, click on End task. Not to worry here, if it’s a system based task, you won’t be able to kill it anyway. Even if you have administrator access.

2. Delete File Using Third Party Tool

Administrator access denied? Don’t worry. There is a neat 3rd party solution that can help getting rid of files and even folders that Windows won’t let you delete. It’s called Unlocker and once you’ve downloaded and installed it, all you gotta do is right-click on the files/folders and then select Unlocker.

Here, you might get a list of processes which are associated with a certain file or folder. Click on Unlock All and this should free up the file/folder to be removed. If it doesn’t work, try Kill Process.

3. Delete File Using Command Prompt

This option is for those who have some experience with Microsoft Windows command prompts. Go to Start menu or press the Windows button on your keyboard and go to Run or just press Win+R. A tiny box will appear at the bottom right corner of your desktop.

Here, type in Cmd and press Enter to open command prompt. You will now see a black window, enter the command line del /f filename there. Make sure the ‘filename’ is the name of the file you want to delete. You can also force delete multiple files that you can specify using commas.

You can also delete a folder using command prompt. Do the above steps till you find the command window and type in the command line RD /S /Q . Here, the file path would be what the address bar on windows explorer is showing when you go to the folder that you want to delete. For example, RD /S /Q C:\Users\XXX\Premium\Folder X.

Читайте также:  Управление вентилятором компьютера mac os

4. Safe Boot if All Else Fails

If nothing works out, then Safe Boot is the ultimate savior. Do this step only if you’ve tried all else and not had any luck. There are plenty of ways to go in Safe Mode, but the one I like most if by typing msconfig in the search box of Windows 10 and then heading over to the Boot tab of the window that pops up.

Here, select the Safe boot option and once you click Apply you will be prompted to reboot the system.

It will now automatically take you to the Safe Mode, where you can delete the file. To get back to the regular mode, go back to the MSCONFIG window and uncheck Safe boot from the boot menu and the PC will reboot back to its normal state.

Any Alternatives?

These are the best options for removing files/folders that won’t go without a fight. But, if you have better alternatives, then we’d like to hear back. Join us in our forums to discuss.

Last updated on 5 Jul, 2019
The above article may contain affiliate links which help support Guiding Tech. However, it does not affect our editorial integrity. The content remains unbiased and authentic.

How to Enable or Disable Confirm on Delete Files Pop-up in Windows 10

Are you irked by the # Windows confirmatino whenever you want to delete files? Here’s a guide on how to enable or disable confirm on delete files pop-up on # Windows 10.

7 Best Ways to Fix Kindle for PC Desktop App Won’t Open on Windows

Can’t open the Amazon # Kindle app on your # desktop PC? Here are some solutions to fix that issue so you can get back to reading your books in peace in your free time.

What Is Microsoft Power Automate Desktop and Why Do You Need It

Everything you need to know about # Microsoft # Power Automate Desktop. Where to get it, how to use it, how to create your first workflow, and who should use it. Complete guide.

6 Best Ways to Fix Action Center Greyed Out on Windows 10

Is the Action Center greyed out on your # Windows 10 computer? Here is an in-depth look at all the solutions that can help you fix this issue promptly.

8 Best Ways to Fix Google Chrome Security Certification Error

Learn how to fix the # Google # Chrome # Security certification error by following the post below.

How to Use Paint 3D to Edit Photos

Wondering how to edit pictures using Paint 3D in # Windows 10? Check our detailed guide on how to use various tools in Paint 3D to edit images.

7 Top Ways to Fix OneNote Notebook Disappearing Error on Windows

Can’t find # OneNote Notebook? Here are a few ways to find missing OneNote notebooks and notes on # Windows 10 computers. Most probably, they are missing and not lost.

6 Best Ways to Fix Store Data Structure Corruption on Windows 10

Facing the BSOD or blue screen of death with the ‘store data structure corruption’ error on your # Windows computer screen? Here are some solutions with explanations to fix it.

Читайте также:  Не устанавливается драйвер nvidia несовместим с данной версией windows

How to delete undeletable & locked files, folders in Windows 10

If you are unable to delete undeletable, locked, ghost folders or files from Windows computer use CMD or a file deleter software to delete undeletable & locked files and folders in Windows 10/8/7.

At times you may find that you are just unable to delete a file or folder on your Windows computer. When you go to delete such ghost or undeletable files or folders you may get an Error message: Could not find this item.

Alternatively, you may also get the following messages:

  • Cannot delete file: Access is denied
  • There has been a sharing violation.
  • The source or destination file may be in use.
  • The file is in use by another program or user
  • The file or directory is corrupted and unreadable.
  • Make sure the disk is not full or write-protected and that the file is not currently in use.

Delete undeletable & locked files, folders

If you cannot delete files or folders in Windows 10 and then try these suggestions to delete the undeletable & locked files, folders:

  1. Reboot and try
  2. Delete in Safe Mode
  3. Run ChkDsk
  4. Use CMD or PowerShell
  5. Use File deleter software.

1] Reboot and try

First, reboot and see if you can delete it.

2] Delete in Safe Mode

Boot in Safe Mode and then try to delete it

3] Run ChkDsk

Run ChkDsk, and then see if you can delete it.

4] Use CMD or PowerShell

Use the del command to delete undeletable files:

Use the RMDIR or RD command to delete undeletable folders:

  • /S : Delete all files and subfolders in addition to the folder itself. Use this to remove an entire folder tree.
  • /Q : Quiet – do not display Y/N confirmation

Be very careful while using this method and use the correct commands.

5] File deleter software

If these methods fail, I suggest you download and use a free file deleter software to delete locked files and folders.

Free File Unlocker, Delete Doctor, Unlcoker, Tizer UnLocker, MoveOnBoot, Wise Force Deleter are some free file deleter software that can help you delete undeletable, hidden, ghost files and folders.

Unlocker unlocks the file or folder if it is being used by any other program and allows you to delete it. Its Explorer integration is a big help, as all you have to do is right on the undeletable folder or file and click on Unlocker.

If no locking handle is found, it will still delete the folder.

Unlocker is a handy tool to have around in such circumstances, BUT it comes with a pre-checked option of installing a QuickStores toolbar for eBay, Amazon & Shopping.com. It also places two eBay internet shortcuts on your desktop. You may want to uncheck these options.

Date: August 20, 2019 Tags: Folder, Freeware

Neat Download Manager for Windows 10 will speed up your downloads

Best Free Ping Monitor Tools for Windows 10

Best Free 8085 Microprocessor Simulators for Windows 10

[email protected]

Anand Khanse is the Admin of TheWindowsClub.com, a 10-year Microsoft MVP (2006-16) & a Windows Insider MVP. Please read the entire post & the comments first, create a System Restore Point before making any changes to your system & be careful about any 3rd-party offers while installing freeware.

Primary Sidebar

report this ad

Оцените статью