I have an wxWidget application built using C++. One of the functionalities of the application is that it prompts the user to enter a string in a message box and then once users presses Enter, it creates a file with the name of the file being the string array user entered.
Now I have an issue, I want to check if the string entered by the user can be a valid name or not**.
-
one way is to check if the file has been created on the system and tell the user it is an invalid string.(I dont want to do this).
-
another would be to parse the entire string to check if it has invalid file name characters like <, /, \ etc in the string.
Is there any other way I can check this which doesn’t involve any file operations?
You could use the static function:
to get a list of invalid characters to match against your string. You can see its documentation here. Although it wont rule out all invalid filenames, it might be good enough for what you want.