Microsoft Yet Again Confounds Me In Ways I Never Would Have Predicted – A Trajedy in One Part
I know this will come as a surprise to some of you, but Microsoft Windows really is a terrible operating system. A joke. A bad car accident. The underage kid that’s getting drunk for the first time at a yuck-a-flucks party and is vomiting uncontrollably in the back corner of the hosts basement where the mess won’t be found for a few days. I discovered the most obscure, nonsensical bug in Windows XP today (for the record I’m running SP3). I’d be very curious to know if this bug exists in Vista – please chime in if you know.
What I Tried to Do
I’m in the middle of writing an application that’s heavily file based. As part of this application I have an archive of definition files that can be updated by the user whenever they want. When the application starts up it checks for a new and improved version of the archive and decompresses it. We’re not talking rocket science here… pretty straight forward and simple, hey? I thought so too… until my Unit Test was inexplicably failing… repeatedly… for hours.
I debugged and debugged… I read and I read… what the heck is wrong? The error made zero sense:
System.ArgumentException: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of “\\.\” in the path.
Sure, the message makes sense, but the context doesn’t, because I was passing an absolute path to an area deep inside the bowels of my local file system… not on a fileshare or UNC’d uri. No sir, mine was starting at the good ol’ c:\ and all was fine.
More debugging. More reading. More frustration. Less hair. Lots of tears.
A Revelation!
And then my good friend Janak showed me… THIS! Well well well, it just so happens that the file I was attempting to decompress was named “con.xsd”. Apparently that violates Windows’… err… guidelines/internal-workings/stupid-programmer-hack-fix.
Now, I can understand that perhaps “con” is a reserved filename for keyboard input… i can understand that Windows needs to reserve it… but does it need to reserve that name across an entire file system that spans hundreds of gigs? Am I the only one that thinks that it’s absolutely ridiculous to have blanket protection like that? It’s crazy! Compare it to, oh, I don’t know… POSIX’s guidelines for device files.
Microsoft – get your crap together and stop puking all over Peter’s new bath towels. Yeesh….
on August 29, 2008 on 12:57 am
This is holdover from the early DOS days. The simple reason it is supported even today is that there is a lot of legacy and existing programs that depend on these device names NUL, CON, COM1, COM2 etc.. Microsoft choose to provide backward compatibility rather than force people to re-write applications.
I suggest that you read this informative article and its comments to really understand the actual issues involved – http://blogs.msdn.com/oldnewthing/archive/2003/10/22/55388.aspx
on August 29, 2008 on 2:39 am
not only con, but com1, com2… lpt1, lpt2 … – device names
on August 29, 2008 on 5:35 am
You’re pretty young , right ?
That’s like that since the dark ages
on August 29, 2008 on 6:37 am
Unfortunately, people will complain no matter what Microsoft does. What would happen if they took that out and it broke legacy code?
on August 29, 2008 on 9:57 am
@Jayakrishnan, I’ll definitely check out that article – I’d like to get some more insight simply from a learning perspective.
@Gigixu – heh, admittedly I’m young’ish? 29, been developing for 7 years but have worked with computers for about 15. I’ve just never come up against this problem the whole time… kinda caught me off guard.
@Ryan (the other ryan) – yea, I can understand backwards compatability, and I can understand reserving device names – what I don’t get, however, is why that reservation is a blanket reservation across the entire FS as opposed to, say, simply under a certain directory as it is in *nix (/dev).
I’ll read jay’s article that he linked. I’m interested.
Thanks for all the comments guys – mucho appreciated.
on September 5, 2008 on 2:40 pm
On Windows 95/98, you could use this to crash any machine with file sharing turned on.
From the malicious machine: Start -> Run -> \\victim-machine\con\con
Bam, BSOD
on September 5, 2008 on 2:49 pm
that, Tony, is astoundingly incredibly sadly awesome.
on September 9, 2008 on 6:04 am
Why not just use a reserved character to indicate a special file? Like ‘#CON’?
on September 9, 2008 on 6:07 am
What I mean is, this is bad, even if your excuse is “DOS 1″.