Windows 和重命名文件夹,“骗局”问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/448438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows and renaming folders, the 'con' issue
提问by Subliminal Hash
Why in Windows, can't you name a folder 'con'?
为什么在 Windows 中,不能将文件夹命名为“con”?
Whenever I try to name a folder as "con" (without the quotes) it defaults to its original name.
每当我尝试将文件夹命名为“con”(不带引号)时,它默认为其原始名称。
Why does it do this?
它为什么这样做?
回答by Joel Coehoorn
Back in the MS-DOS days, "con" had a special meaning. It referred to the console, and allowed you to treat it like any other file. For example, you might create a new text file by typing copy con new.txt
. Then you could enter your text and hit ^Z
when finished.
回到 MS-DOS 时代,“con”具有特殊含义。它引用了控制台,并允许您像对待任何其他文件一样对待它。例如,您可以通过键入创建一个新的文本文件copy con new.txt
。然后你可以输入你的文字并^Z
在完成后点击。
The thing is, you can still do that. Therefore, as far as the file system is concerned there is already an object out there named con
. There are other reserved namesas well, but I see that while typing this those names have been provided already in other answers.
问题是,你仍然可以这样做。因此,就文件系统而言,已经有一个名为con
. 还有其他保留名称,但我看到在输入这些名称时,其他答案中已经提供了这些名称。
回答by strager
Do not use the following reserved device names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9
不要使用以下保留设备名称作为文件名:
CON、PRN、AUX、NUL、COM1、COM2、COM3、COM4、COM5、COM6、COM7、COM8、COM9、LPT1、LPT2、LPT3、LPT4、LPT5、LPT6、LPT7、LPT8和LPT9
Other names, such as drive names, cannot be used as well:
也不能使用其他名称,例如驱动器名称:
CLOCK$, A:-Z:
时钟$, A:-Z:
回答by strager
Actually you can rename the folder to con
其实你可以将文件夹重命名为 con
use this in the command prompt and this creates a system folder named con
on your C: Drive
在命令提示符中使用它,这将创建一个名为con
C: 驱动器的系统文件夹
md \\\.\\C:\con
to remove this folder you need to use this in the command prompt
要删除此文件夹,您需要在命令提示符中使用它
rd/s \\.\\C:\con
And just for those that are wondering "so why would you?" - my name is CON and if I wish to use that as my folder I WILL so "bugger you MS"
而对于那些想知道“那你为什么要这样做呢?”的人来说。- 我的名字是 CON,如果我想用它作为我的文件夹,我会“烦死你”
Con "OzDing"
Con“OzDing”
回答by MattK
This dates back to MS-DOS. Reading or writing to a file named "CON:" read/wrote from the console. I imagine Windows is still supporting this for backwards compatibility.
这可以追溯到 MS-DOS。从控制台读取或写入名为“CON:”的文件。我想 Windows 仍然支持它向后兼容。
回答by Michael Itzoe
From Microsoft TechNet:
来自微软技术网:
Several special file names are reserved by the system and cannot be used for files or folders:
CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, NUL
系统保留了几个特殊文件名,不能用于文件或文件夹:
CON、AUX、COM1、COM2、COM3、COM4、LPT1、LPT2、LPT3、PRN、NUL