Reserved File Name Followed by Extension Names Behaves out of Expectation

VoxelH 20 Reputation points
2026-08-22T17:32:11.79+00:00

I am a beginner learning Win32 Local FileSystems to better deal with files on Windows.

In the article (Naming Files, Paths, and Namespaces)[https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file], it is said the some reserved file names, such as COM1, CON, and NUL, are prohibited to use. Even files whose names start with the same one in those reserved names and immediately followed by extension name(s) are equivalent, such as NUL and NUL.txt .

To get a deeper understanding of paths, I read https://projectzero.google/2016/02/the-definitive-guide-on-win32-to-nt.html?utm_source=chatgpt.com. But things get a little bit weird as it and MSLearn Document both described.

1

First, though NUL is prohibited to create in file explorer, but NUL.txt is still allowed to create. However, it cannot be opened normally, for instance using VSCode to access it results in a default welcome window, instead of a document window.

2

Second, I recently created a NTFS volume F: with a capacity of 100MB to test filesystem behaviors. I created F:\NUL.txt, and used powershell instruction cat <a_30MB_zip_file> > F:\NUL.txt to write data to it. Powershell raised an error half the way, and said that there's no enough space to write. Checking what's going on in the File Explorer, I surprisely found out that Volume F:/ has 0 byte left, while NUL.txt has a size of about 40MB. I expected the behavior was like no matter how much data I wrote to it, the actual size would be 0.

User's image User's image

3

Third, when I use the code https://projectzero.google/2016/02/the-definitive-guide-on-win32-to-nt.html?utm_source=chatgpt.com provided at the bottom of the website, I found out that a reserved file name suffixed by an extension name cannot be parsed to the corresponding NT Path: CON.txt C:\CON.txt C:CON.txt \CON.txt are converted just like normal files. And that is different from what It should be like as the second chart in the "Local Device" section of https://projectzero.google/2016/02/the-definitive-guide-on-win32-to-nt.html?utm_source=chatgpt.com.

CON.txt
RelativeName: 'CON.txt'
Directory:    0x64
CurDirRef:    0x1ABD9D19660
FullPathName: 'D:\Development\ConsoleApp1\ConsoleApp1\bin\Debug\net10.0\CON.txt'
/CON.txt
Converting:   '/CON.txt'
To:           '\??\D:\CON.txt'
Type:         RtlPathTypeRooted
FileName:     CON.txt
FullPathName: 'D:\CON.txt'
C:/CON.txt
Converting:   'C:/CON.txt'
To:           '\??\C:\CON.txt'
Type:         RtlPathTypeDriveAbsolute
FileName:     CON.txt
FullPathName: 'C:\CON.txt'
C:CON.txt
Converting:   'C:CON.txt'
To:           '\??\C:\CON.txt'
Type:         RtlPathTypeDriveRelative
FileName:     CON.txt
FullPathName: 'C:\CON.txt'

(pls ignore that I used forward slash. The same things happened when I used backslash in their paths)

Since they are equivanlent to CON, I expected them to behave like CON -- translated to \??\CON

Is this just a misbehavior, or an internal implementation that ordinary users and win32 developers should not focus on? (but I think there will be some guys who will try to create NUL.txt -- we've got billions of WIndows users)

OS: Win11 Chinese Simplified Home Insider Preview (25H2 26220.9202)

Windows for home | Other | Files, folders, and storage
0 comments No comments

Answer accepted by question author
Igor Leyko 112.2K Reputation points Independent Advisor
2026-08-23T07:51:08.0266667+00:00

Please see documentation: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file

Do not use the following reserved names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM¹, COM², COM³, 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.

The result may be unpredictable.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Newest
  1. Igor Leyko 112.2K Reputation points Independent Advisor
    2026-08-23T07:51:44.1433333+00:00

    [duplicate]

    Was this answer helpful?

    0 comments No comments

  2. Igor Leyko 112.2K Reputation points Independent Advisor
    2026-08-22T18:10:45.62+00:00

    Please do not expect any certain behavior when you try to bypass reserved file names limitations. The result may be unpredictable. This is by design.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.