gpt4 book ai didi

windows - 如何删除 Windows 上以点 (.) 结尾的目录?

转载 作者:行者123 更新时间:2023-12-05 01:33:02 24 4
gpt4 key购买 nike

我错误地创建了一个文件,而且我这辈子都无法删除它。如果你有 7-Zip安装好了,就可以生产了。如果没有,很容易安装。

文件的创建方式如下:

PS C:\temp> mkdir abc
PS C:\temp> cd abc

PS C:\temp\abc> & 'C:\Program Files\7-Zip\7z.exe' a -spf .\DuoWindowsLogon.admx,.\en-us\DuoWindowsLogon.adml

Creating archive: .\DuoWindowsLogon.admx,.\en-us\DuoWindowsLogon.adml

后来,我了解到我应该输入的正确命令是:

& 'C:\Program Files\7-Zip\7z.exe' a abc.7z -spf DuoWindowsLogon.admx en-us\DuoWindowsLogon.adml

意识到错误后,我尝试删除错误创建的目录:

PS C:\temp\abc> ls
d----- 11/15/2020 11:09 PM DuoWindowsLogon.admx,.

PS C:\temp\abc> ls D*
ls : Could not find item C:\temp\abc\DuoWindowsLogon.admx,..

PS C:\temp\abc> ls | rm
rm : Cannot find path 'C:\temp\abc\DuoWindowsLogon.admx,.' because it does not exist.

PS C:\temp\abc> rm *
rm : An object at the specified path C:\temp\abc\DuoWindowsLogon.admx,. does not exist.

PS C:\temp\abc> cd ..
PS C:\temp> rm -recurse abc
rm : Could not find a part of the path 'C:\temp\abc\DuoWindowsLogon.admx,'.

如您所见,没有任何效果。我还尝试了文件资源管理器 (GUI),它也不起作用。如何删除目录?

附言:

我在 CMD 提示符下尝试了“del/s”,它没有产生错误,但文件没有被删除:

c:\>del /s c:\temp\abc
c:\temp\abc\*, Are you sure (Y/N)? Y

c:\>dir c:\temp\abc
11/15/2020 11:09 PM <DIR> DuoWindowsLogon.admx,.

最佳答案

您可以删除以“.”结尾的目录。通过在其前面加上 \\?\

前缀

因此,在您的情况下,您可以使用:

Remove-Item `\\?\C:\temp\abc\DuoWindowsLogon.admx,.` -Recurse

此处记录:You can't delete a file or a folder on an NTFS file system volume

You may not be able to delete a file if the file name includes aninvalid name (for example, the file name has a trailing space or atrailing period or the file name is made up of a space only). Toresolve this issue, use a tool that uses the appropriate internalsyntax to delete the file. You can use the "\\?\" syntax with sometools to operate on these files, for example:

del "\\?\c:\<path_to_file_that contains a trailing space.txt>"

The cause of this issue is similar to Cause 4. However, if you usetypical Win32 syntax to open a file that has trailing spaces ortrailing periods in its name, the trailing spaces or periods arestripped before the actual file is opened.

关于windows - 如何删除 Windows 上以点 (.) 结尾的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64851490/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com