Reserved file names cannot be used. We can detect these names in strings in a C# program. This ensures we do not generate an invalid file name.
Some examples. Some reserved file names are CON.txt, PRN.doc and nul.exe. If we need to generate file names, we can test to ensure we do not choose a reserve done.
Reserved list. Here is a list of file names that cannot be used in Windows. On other operating systems like Linux and macOS these file names are not reserved.
Example code. This issue can occur when a Windows server tries to serve a file such as PRN.aspx, which is dynamically generated. This code can detect such invalid file names.
A summary. We saw a useful method—it can detect the invalid file names that Windows reserves. This includes all the Windows server environments, such as IIS.
Dot Net Perls is a collection of tested code examples. Pages are continually updated to stay current, with code correctness a top priority.
Sam Allen is passionate about computer languages. In the past, his work has been recommended by Apple and Microsoft and he has studied computers at a selective university in the United States.
This page was last updated on Jun 2, 2021 (rewrite).