开发者

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

开发者 https://www.devze.com 2023-03-04 04:06 出处:网络
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 wil

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:\newpro开发者_Go百科ject". How should I do this?


Use System.IO.Path.IsPathRooted:

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

精彩评论

暂无评论...
验证码 换一张
取 消