windows - Safe/Allowed filename cleaner for .NET -


Whether to take an arbitrary string in .NET in a standardized / librid / tested way and to confuse it in such a way that Does it represent a valid filename?

It is easy to roll your own four-replacement function, but I should make a little more strong and revive.

This problem is not as simple as you think it is. Not only are these that are eligible in path.GetInvalidFileNameChars , there are many filenames, such as "PRN" and "Conn", which are reserved by Windows and can not be made. Any name that is "." Besides, there is also illegal in Windows, there are different length limitations. Read the complete list.

If that is not enough, different file systems have different limitations, for example the ISO9660 filename can not start with "-", but it may be included.


Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

mysql - Can mysql_pconnect be called multiple times in one php page? -