文件路徑或者保存模板出現非法字符判斷
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 動態庫即可。
新聞熱點
疑難解答