Cannot delete corrupted folder in windows 10

Solution 1:

Your problem is that you have a file system entry with a name containing only a space (test\ , note the space after the backslash). This is technically possible in NTFS, but is not at all permitted in Win32 and most Windows APIs will not handle it gracefully at all. They will try to strip the spaces from the ends of the file name, and then get very confused when the filename isn't there anymore and may treat it as though you're referring to the directory; this happens even if you use a format like test\* or " ".

There are two ways out of this within Windows itself.

  1. Bypass the Win32 path translation. This is done by prefixing a fully-qualified path with \\?\. Doing this turns off all of the Win32 rules about what is a valid file name (such as "cannot begin or end with a space"), leaving only the much smaller set of NTFS rules (cannot contain a \ or :, for example). Note that it also turns off convenient shorthands like using relative paths; if you want to do this you must supply an absolute path (C:\Users\mandar\Desktop\test\ ) and you will need to quote it so the command line knows you meant to include that final space: del "\\?\C:\Users\mandar\Desktop\test\ " (and yes, you should be using cmd.exe for this; Powershell ignores the \?\ and Unix-like shells running on Windows via MinGW or Cygwin don't use paths of the format the kernel expects).
  2. Use the native Linux subsystem in Windows (which runs unmodified Linux binaries directly on the NT kernel, through a special driver). Linux (as you found) supports dealing with files that have silly names like and so does WSL, the Windows Subsystem for Linux. If you haven't used WSL before, you'll need to install some Linux distro from the Windows app store (Ubuntu and OpenSUSE are both available and suitable for general use, Kali is also available if you want a special-purpose distro on your Windows box; you can install more than one if you want). From within bash (or other shell) of a WSL distro, navigate to the relevant directory (cd /mnt/c/Users/mandar/Desktop/test) and then delete the offending file (rm ' ') or simply the whole directory.

Solution 2:

Run the command chkdsk and see if it finds errors.

For further understanding the errors, it is possible to Read Chkdsk Log in Event Viewer in Windows 10.

If errors are found, and if they don't sound too menacing or there are too many of them, to fix the errors run the command:

chkdsk /f

Ensure having a good backup of your files before starting.