/// <summary> /// 检查文件名是否有效。 /// </summary> /// <param name="FileName"></param> public static Boolean CheckFileName(String fileName) { Boolean isValid = true; String[] strList = new String[] { " ", "/", "\"", @"\", @"\/", ":", "*", "?", "<", ">", "|", "\r\n" }; if (String.IsNullOrEmpty(fileName)) { isValid = false; } else { foreach (String errStr in strList) { if (fileName.Contains(errStr)) { isValid = false; break; } } } return isValid; }