Windows reserves certain filenames (CON, PRN, AUX, NUL, COM0-COM9, LPT0-LPT9) inherited from DOS for backward compatibility. These names are case-insensitive and cannot be used with extensions either. While Win32 APIs enforce this restriction, the underlying file systems (NTFS, FAT32, ReFS) do not — meaning WSL or the `\?\` path prefix can bypass it. In .NET, accessing such filenames via standard System.IO APIs throws an IOException, and Path.GetInvalidFileNameChars() does not flag them. Using the `\?\` prefix in .NET allows creating, reading, and deleting files with reserved names. The Meziantou.Framework.FullPath NuGet package handles this automatically by applying the prefix internally when reserved names are detected.

4m read timeFrom meziantou.net
Post cover image
Table of contents
## Win32 API vs. File System## Creating reserved files with WSL## Accessing reserved files in .NET## Bypassing the restriction## Additional resources

Sort: