- 文件名中非法字符,统一替换为下划线
//文件名中非法字符 统一替换为下划线
public string GetNewName(string fileName)
{
if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)//GetInvalidPathChars()
{
string invalid = new string(Path.GetInvalidFileNameChars());
foreach (char c in invalid)
{
fileName = fileName.Replace(c.ToString(), "_");
}
}
return fileName;
}