在 Windows 中仅命名带有扩展名的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1357502/
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
Only Name File with Extension in Windows
提问by JasCav
I am trying to create a file in Windows XP that is onlythe extension (".classpath" and ".project"). While my Linux box handles this appropriately, Windows gives me the error, "You must type a file name."
我试图在 Windows XP 中创建一个只有扩展名(“.classpath”和“.project”)的文件。虽然我的 Linux 机器适当地处理了这个问题,但 Windows 给了我错误,“你必须输入一个文件名。”
Any suggestions how to do this? I am attempting to setup an Eclipse project where I can bring in the classpath and project files from someone else's setup and I keep getting the above error.
任何建议如何做到这一点?我正在尝试设置一个 Eclipse 项目,我可以从其他人的设置中引入类路径和项目文件,但我不断收到上述错误。
回答by knittl
use the commandline to do this, windows explorer doesn't allow renamed files to start with a period. first create the file/directory with a dummy name x.ext, then fire up cmd.exe and rename it:
使用命令行执行此操作,Windows 资源管理器不允许重命名的文件以句点开头。首先使用虚拟名称 x.ext 创建文件/目录,然后启动 cmd.exe 并重命名它:
ren x.ext .ext
this way you can also create directories which names start with a period (like .git or .meta)
通过这种方式,您还可以创建名称以句点开头的目录(如 .git 或 .meta)
回答by Alex Lapa
Just name your file with additional dot at the end: ".ext." explorer will remove additional dot and you'll get .ext file.
只需在文件末尾加上点命名您的文件:“.ext”。资源管理器将删除额外的点,您将获得 .ext 文件。
回答by RedFilter
From the command line:
从命令行:
echo some text > .classpath
回答by vkolodrevskiy
Windows seems not to be in control of how Save dialogs handle forbidden characters
Windows 似乎无法控制保存对话框如何处理禁用字符
回答by Till Theis
Quoting the filename should do the job.
引用文件名应该可以完成这项工作。
I have no Windows machine to try it out but I was able to save a ".htaccess" file in Notepad this way.
我没有 Windows 机器可以尝试,但我能够以这种方式在记事本中保存“.htaccess”文件。