C # check if the specified file path contains the root directory

How can I check if the given file path for the console application contains the root directory? for example, a person enters the value of the argument "false" for an argument that is looking for a path. It will create the path to the false folder of the default directory. Instead, I want it to accept only the argument if the provided argument has the form, for example, "C: \ newproject". How should I do it?

+3
source share
1 answer

Use System.IO.Path.IsPathRooted :

if(Path.IsPathRooted(path))...
+8
source

All Articles