How to safely save file to disk without the risk of windows reject it?

扶醉桌前 提交于 2019-12-23 12:42:34

问题


I'm developing a winform application. I want to take input from user (i.e. the user provides username) and use that input as part of filename and save to file.

How do I check if the username provided by the user didn't contain windows' reserved characters. And what is the list of reserved characters for windows?


回答1:


via:

    Path.GetInvalidFileNameChars()

and

    Path.GetInvalidPathChars()

The exact list could be platform-specific (especially for mono), and it includes some non-printable characters... so showing you them here is tricky ;p



来源:https://stackoverflow.com/questions/6544851/how-to-safely-save-file-to-disk-without-the-risk-of-windows-reject-it

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