Handle files with very long names in Windows

Yesterday I stumbled upon a problem that is quite unusual: a user has been able to download a file with a very long name, and since Windows can only handle path of 259 characters for files it was impossible to delete or rename the file.
I tried in cmd to use the legacy DOS 8+3 name (FILENA~1.TXT) but still it was struggling recognizing the path.
So searching I found this solution that worked:
- Shift-right-click the file name in Explorer and select Copy as path.
- Open a Cmd window (⊞-R cmd).
- Enter del \\?\ and then right-click to paste in the copied path. The result should look something like this:
del \\?\"C:\Users\SomeUser\Downloads\VERYLO~1.TXT"
- Press Enter to delete the file.
Note: In Windows 11, Copy as path is also available with just a right-click (i.e. shift not needed).