Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get reserved file names in Windows

Tags:

c#

.net

windows

It's known, you can't create a file with name con (con.txt for example) in Windows. So, in my application user can input a custom file name (not via SaveFileDialog, just textbox to input name, not full path), and I want to show an error message, when user inputs invalid file name. Is there a way to get full list of reserved Windows file names (con, prn, lpt and so on)?

like image 289
Backs Avatar asked Sep 14 '15 09:09

Backs


2 Answers

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, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.

Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended.

As per: https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247(v=vs.85).aspx

like image 191
Jeremy Thompson Avatar answered Sep 19 '22 22:09

Jeremy Thompson


Take a look here: Reserved file names

Reserved filenames in Windows operating systems

aux con clock$ nul prn com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9

like image 29
Rubens Farias Avatar answered Sep 21 '22 22:09

Rubens Farias