You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following fundamental rules enable applications to create and process valid names for files and directories, regardless of the file system:
...
Do not use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM0, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM¹, COM², COM³, LPT0, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT¹, LPT², and LPT³. Also avoid these names followed immediately by an extension; for example, NUL.txt and NUL.tar.gz are both equivalent to NUL. For more information, see Namespaces.
Note
Windows recognizes the 8-bit ISO/IEC 8859-1 superscript digits ¹, ², and ³ as digits and treats them as valid parts of COM# and LPT# device names, making them reserved in every directory. For example, echo test > COM¹ fails to create a file.
pathvalidate doesn't catch these cases:
COM or LPT followed by 0 or the superscript digits 1, 2, or 3.
The use of any of these reserved names followed by a multi-part file name extension.
Inside a Windows 11 VM with an NTFS filesystem, I was able to confirm that some of these filenames were illegal, but I was also able to create files com0, lpt0, and com1.foo.bin.
At first glance, those last three names seem like they should be illegal, but the Microsoft article states that it lists general rules "regardless of the file system", so to ensure strict conformance, I would recommend also catching COM0, LPT0, and otherwise-reserved names with multi-part extensions.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi,
Quoting the Microsoft article Naming Files, Paths, and Namespaces, section "Naming Conventions":
pathvalidate
doesn't catch these cases:COM
orLPT
followed by0
or the superscript digits 1, 2, or 3.The use of any of these reserved names followed by a multi-part file name extension.
Yields:
Inside a Windows 11 VM with an NTFS filesystem, I was able to confirm that some of these filenames were illegal, but I was also able to create files
com0
,lpt0
, andcom1.foo.bin
.At first glance, those last three names seem like they should be illegal, but the Microsoft article states that it lists general rules "regardless of the file system", so to ensure strict conformance, I would recommend also catching
COM0
,LPT0
, and otherwise-reserved names with multi-part extensions.Thanks!
The text was updated successfully, but these errors were encountered: