文件路径或者保存模板出现非法字符推断

文件路径或者保存模板出现非法字符推断


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 动态库就可以。


posted @ 2017-05-10 17:42  yxysuanfa  阅读(1033)  评论(0编辑  收藏  举报