保存文件的时候,文件名不允许非法字符。

 

        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, ""));
}

相关文章:

  • 2022-12-23
  • 2022-02-16
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2021-12-24
  • 2021-12-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-09-03
  • 2021-06-20
  • 2021-10-10
  • 2022-12-23
相关资源
相似解决方案