If you want “bad” filenames to generate an error:
if (Path.GetFileName(fileName) != fileName)
{
throw new Exception("'fileName' is invalid!");
}
string combined = Path.Combine(dir, fileName);
Or, if you just want to silently correct “bad” filenames without throwing an exception:
string combined = Path.Combine(dir, Path.GetFileName(fileName));