public static string GetFileName (string path)
{
if (path == null || path.Length == 0)
return path;
if (path.IndexOfAny (InvalidPathChars) != -1)
throw new ArgumentException ("Illegal characters in path.");
int nLast = path.LastIndexOfAny (PathSeparatorChars);
if (nLast >= 0)
return path.Substring (nLast + 1);
return path;
}