保存文件的时候,文件名不允许非法字符。
public string ReplaceSpecialCharacter(string str)
{
List<char> charArr = new List<char>() { '\\', '/', '*', '?', '"', '<', '>', '|', ':' };
return charArr.Aggregate(str, (current, c) => current.Replace(c, ' '));
}
public string ReplaceSpecialCharacterV2(string str)
{
List<string> charArr = new List<string>() { "\\", "/", "*", "?", "<", ">", "|", ":" ,"\""};
return charArr.Aggregate(str, (current, c) => current.Replace(c, ""));
}