I am writing a small tool that needs to create lot of files with different names(9000+). Then I got one strange error message:
System.ArgumentException occurred HResult=-2147024809 Message=FileStream will not open
Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path.
Source=mscorlib StackTrace: at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access,
Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,
SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy,
Boolean useLongPath, Boolean checkHost) InnerException:
I did some research and found out the reason. I have listed the results here to share with you. Hope it will save you some time in the future.
Microsoft has reserved the following words that cannot be used as file names:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.?
turns good thoughts into actions...