VC++ 6.0 中遇到的问题,——文件命名prn 有错

roli 2002-08-29 12:50:35
各位大虾们

今天小弟遇到意见怪事,
我照着书本上的程序代码过程中需要命名一个叫“prn.c”的源文件时,

VC++跳出窗口 说:“The specified filename is invalid.”
这是这么回事儿呀!!
清指教!!!
...全文
139 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
roli 2002-09-01
  • 打赏
  • 举报
回复
谢谢,我这次明白什么意思了,虽然我现在还没有接触那么多,

谢谢大家了
Tommy 2002-08-30
  • 打赏
  • 举报
回复
就是上面ahao(天·狼·星星)的帖子中说的原因,CON, PRN, AUX, CLOCK$, NUL, COM1 - COM9, LPT1 - LPT9都是系统保留的文件名,是为了和DOS兼容保留的,不能用这些名字作为文件名。

解决办法只有不用这些名字作为文件名。
roli 2002-08-30
  • 打赏
  • 举报
回复
可是,为什么,prn就不能做文件名呢,这和你说的有关系吗??juqiang(方枪枪(正在升级为惊艳一枪。。。))
roli 2002-08-30
  • 打赏
  • 举报
回复
当然没有那种错误,

juqiang 2002-08-29
  • 打赏
  • 举报
回复
这是系统的几个设备之一,你可以在command prompt模式下,运行type 1.txt>prn,那么1.txt就被自动打印到打印机上了。
ahao 2002-08-29
  • 打赏
  • 举报
回复
PRB: File Routines Fail with Some File Names (CON, PRN, AUX, CLOCK$, NUL, COM1 - COM9, LPT1 - LPT9)

Q216654


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Windows NT Server versions 3.5, 3.51, 4.0
Microsoft Windows NT Workstation versions 3.5, 3.51, 4.0
Microsoft Windows 98
Microsoft Windows 95
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Server
Microsoft Windows 2000 Professional

--------------------------------------------------------------------------------


SYMPTOMS
File creation, deletion, read, write, and manipulation routines fail or behave unpredictably when dealing with a file with one of the following names: CON, PRN, AUX, CLOCK$, NUL, COM1 - COM9, LPT1 - LPT9.

To illustrate this, start a command prompt under Windows 9x or Windows NT. Copy any file to an unused name; for example, Testfile.tmp. Now, type in the command REN testfile.tmp CON.

RESULTS: You get an error that states the file already exists.



CAUSE
This problem is caused by name collision with the reserved device names. These names are reserved by Windows 95, Windows 98, Windows NT, and Windows 2000 for backwards compatibility with MS-DOS, which reserved these names for various devices. If these device names were not reserved, one could no longer use the following standard MS-DOS syntax (from a command prompt) to create a text file:


COPY CON testfile.txt
or the following method to view it:
COPY testfile.txt CON
or the following method to print it:
COPY testfile.txt PRN
or the following method to output text typed from the keyboard to the printer:
COPY CON PRN



RESOLUTION
These names must be avoided when creating file names.



STATUS
This behavior is by design, for backwards compatibility with MS-DOS applications, and is a consequence of the MS-DOS device driver architecture. Because legacy MS-DOS applications, or MS-DOS applications ported to console-mode applications, may explicitly use these reserved file names, these file names must be retained as long as MS-DOS backwards compatibility is required in the Windows family.



MORE INFORMATION
Similar behavior may be observed if special legacy-type device drivers that register other reserved names are loaded (for example, by Config.sys or Autoexec.bat).



REFERENCES
For additional information, please see the following article in the Microsoft Knowledge Base:

Q120716 How To Remove Files with Reserved Names in Windows NT

Additional query words: CON PRN AUX CLOCK$ NUL COM1 COM2 COM3 COM4 LPT1 LPT2 LPT3

Keywords : kbFileIO kbKernBase kbOSWinNT350 kbOSWinNT351 kbOSWinNT400 kbOSWin2000 kbOSWin95 kbOSWin98 kbDSupport kbGrpDSKernBase
Issue type : kbprb
Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT351xsearch kbWinNT350xsearch kbWinNT400xsearch kbWinNTW350 kbWinNTW350xsearch kbWinNTW351xsearch kbWinNTW351 kbwin2000AdvServ kbwin2000AdvServSearch kbwin2000S kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbWinNTS351 kbWinNTS350 kbwin2000Ssearch kbwin2000Search kbwin2000ProSearch kbwin2000Pro kbWinNTS351xsearch kbWinNTS350xsearch


Last Reviewed: December 14, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
roli 2002-08-29
  • 打赏
  • 举报
回复
什么意思,打印机的文件名??

DoItFreely 2002-08-29
  • 打赏
  • 举报
回复
可能是你的"."不对吧?是不是打成汉字的点"。"了?
roli 2002-08-29
  • 打赏
  • 举报
回复
看来我得好好学学英语了,看不懂!!
ahao 2002-08-29
  • 打赏
  • 举报
回复
打印机
cky2 2002-08-29
  • 打赏
  • 举报
回复
prn 该不会是打印机的文件名吧

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧