Coffeehouse Post

Single Post Permalink

View Thread: System.IO.FileInfo.FullName
  • User profile image

    I just ended a several day exploration of the FullName Property of the System.IO.FileInfo class in .NET.  When the FullName exceeds in length a certain pre-determined number of characters, the Property throws an Exception.  There are rules, you know.   And limitations.  Funny thing is, it is possible to create a file whose name exceeds the limit.  And said creation does NOT cause any grief at all.  The boobytrap waits around until an innocent user traverses a major subtree, using GetDirectories() in System.IO.DirectoryInfo (similar for files), and stumbles over the illicit item.  Seems a little crazy to permit a user to create a file whose name is illicit.  But what do I know?


    Also, this arbitrary and capricious character limit obviously came about to cater to the needs of C language programmers who would routinely declare a static, one dimension array of characters to contain just about any fully-qualified filename that you are likely to encounter.  Just so Mister C Programmer could aim at something, a limit was established.  That was well before the advent of the native string class, which is far more natural to code with than arrays of characters that terminate in a NUL character.