文件路径或者保存模板出现非法字符判断
1)不为空判断
string strtemplatename = txttemplatename.text; if (string.isnullorwhitespace(strtemplatename)) { show("请输入模板名称!", "提示", .information, ok); txttemplatename.focus(); return; }
2)然后对strtemplatename 进行非法字符判断
if (strtemplatename.indexofany(path.getinvalidfilenamechars()) >= 0) { //含有非法字符 \ / : * ? " < > | 等 show("模板名称含有非法字符,请重新输入", "错误", error, ok); txttemplatename.focus(); return; }
3)path 引用系统的io 动态库即可。
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论