private static bool IsValideFileName(string FileName) { char[] InvalidFileNameChars = System.IO.Path.GetInvalidFileNameChars(); foreach (char InvalidFileNameChar in InvalidFileNameChars) if (FileName.Contains(InvalidFileNameChar.ToString())) return false; return true; } private static string ConvertToValideFileName(string FileName, char RemplaceChar) { char[] InvalidFileNameChars = System.IO.Path.GetInvalidFileNameChars(); foreach (char InvalidFileNameChar in InvalidFileNameChars) if (FileName.Contains(InvalidFileNameChar.ToString())) FileName = FileName.Replace(InvalidFileNameChar, RemplaceChar); return FileName; }