Invalid characters in a filename on Windows?

不打扰是莪最后的温柔 提交于 2019-12-05 16:15:06

Yes, in an ASCII based file system Path.GetInvalidFileNameChars() will guarantee you a safe file name. If you check the ASCII chart here you will find that everything from the left column is excluded and certain characters from the remaining columns are also excluded. Check the decimal representation of each char in the returned array for a full list of what's excluded.

The first part is specifying what characters are prohibited by the language itself. However, since classes are loaded from files with specific names (on most platforms), the underlying platform may impose additional restrictions due to the filesystem. The same is true in Java, though you can technically get around it by using a custom classloader.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!