But the file name must actually be shorter than that, since the complete path (such as C:\Program Files\filename.txt) is included in this character count.
This is why you might occasionally encounter an error when copying a file with a very long file name to a location that has a longer path than its current location.
A method that guarantees, generally, that a Windows filename is valid -- that it would be legal to create a file of that name -- would be impossible to implement.
It is relatively straightforward to guarantee that a Windows filename is the filename is valid on Windows.
All modern versions of Windows natively support NTFS, FAT32, and FAT16 file formats, which accept Unicode filenames.
But drivers for arbitrary filesystems can be installed, and one is free to create a filesystem that doesn't allow, for instance, the letter 'n'.
Thus, not even a simple file like "snowman.txt" can be "guaranteed" to be valid.
But even with extreme cases aside, there are other complications.
For instance, a file named "$Log File" cannot exist in the root of a NTFS volume, but can exist elsewhere on the volume.