/// <summary> /// 去除特殊字符 /// </summary> /// <param name="text"></param> /// <returns></returns> public static string MakeValidFileName(string text) { StringBuilder str = new StringBuilder(); var invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (var c in text) { if (!invalidFileNameChars.Contains(c)) { str.Append(c); } } return str.ToString(); }