The user input string for the destination path may contain spaces or other invalid characters.
Example: "C: \ users \ username \\ directory_name \"
Please note that this has spaces on both sides of the path, as well as an invalid folder name only in the middle. Checking to make sure this is an absolute path is not enough because it really really handles leading spaces. Removing trailing spaces is also not enough, because you are still left with an invalid folder name in the middle.
How can I prove that the path is valid before I try to do something with it?
source
share