删除名为“NUL"的文件在 Windows 上 [英] Delete a file named "NUL" on Windows

查看:13
本文介绍了删除名为“NUL"的文件在 Windows 上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7 上运行了一个程序,该程序是在 Cygwin 下编译的,并将NUL"作为输出文件名传递.它实际上并没有抑制输出,而是在当前目录中创建了一个名为NUL"的文件.(显然它需要/dev/null",即使在 Windows 上也是如此.)现在我被这个无法删除的NUL"文件困住了!

I ran a program on Windows 7 that was compiled under Cygwin and passed "NUL" as an output file name. Instead of suppressing output it actually created a file named "NUL" in the current directory. (Apparently it expects "/dev/null", even on Windows.) Now I'm stuck with this "NUL" file that I cannot delete!

我已经试过了:

  • Windows 资源管理器 - 错误:无效的 MS-DOS 功能"(是的,它说的是真的!)
  • 使用del NUL"的命令提示符 - 错误:文件名、目录名或卷标签语法不正确."
  • 删除整个目录 - 与删除文件相同
  • remove() 在 C 程序中 - 也失败
  • Windows Explorer - error: "Invalid MS-DOS function" (yes, that is seriously what it says!)
  • Command prompt using "del NUL" - error: "The filename, directory name, or volume label syntax is incorrect."
  • Deleting the entire directory - same deal as just deleting the file
  • remove() in a C program - also fails

如果没有安装完整的 Cygwin 环境并在 Cygwin 下编译 C 程序,我如何摆脱这些 NUL 文件(我现在有几个)?

How can I get rid of these NUL files (I have several by now), short of installing the full Cygwin environment and compiling a C program under Cygwin to do it?

推荐答案

打开命令提示符并使用这些命令先重命名然后删除 NUL 文件:

Open a command prompt and use these commands to first rename and then delete the NUL file:

C:> rename \.C:..NUL. deletefile.txt
C:> del deletefile.txt

使用 \. 前缀告诉高级文件 I/O 函数将未解析的文件名传递给设备驱动程序 - 这样您就可以访问其他无效名称.

Using the \. prefix tells the high-level file I/O functions to pass the filename unparsed to the device driver - this way you can access otherwise invalid names.

阅读这篇文章,了解有效Windows 中的文件/路径名和各种保留名称.

Read this article about valid file / path names in Windows and the various reserved names.

这篇关于删除名为“NUL"的文件在 Windows 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆