karlstackoverflow
karlstackoverflow

Reputation: 3418

c# check if a given file path contains a root directory

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

Upvotes: 3

Views: 2195

Answers (1)

manji
manji

Reputation: 47978

Use System.IO.Path.IsPathRooted:

if(Path.IsPathRooted(path))...

Upvotes: 8

Related Questions