public static boolean isValidName(String text)
{
Pattern pattern = Pattern.compile(\"^[^/./\\\\:*?\\\"<>|]+$\");
Matcher matcher = pattern.matcher(text
You can check all the reserved names (AUX, CON, and the like) and then use this code:
bool invalidName = GetFileAttributes(name) == INVALID_FILE_ATTRIBUTES &&
GetLastError() == ERROR_INVALID_NAME;
to check for any additional restriction. But note that if you check for a name in a non existant directory you will get ERROR_PATH_NOT_FOUND whether the name is really valid or not.
Anyway, you should remember the old saying:
It's easier to ask for forgiveness than it is to get permission.