Hello All,
Hello All,
Directory.Exists(Path.GetDirectoryName( FilePath);
Directory.Exists(Path.GetDirectoryName(FilePath);
即使目录不存在,它也会返回true。
It returns true even if the directory is not present.
任何想法?
推荐答案
尝试编写简单的控制台程序并将您输入的路径提供给Path.GetDirectoryName(),您将看到。它由 文档如果在提供的参数中没有"路径"组件(即:由"\\"或"/"组成的字符串),它将返回String.Empty ,它被视为当前目录。
Try write simple console program and feed the path you entered to Path.GetDirectoryName() and you'll see.It is spelt out by the documentationifthere aren't "path" component in the parameter supplied (i.e.: strings separated by "\\" or "/"),it'll return String.Empty, which is treated as the current directory.
要测试FilePath是否存在,只需将路径放到Directory.Exists()。
To test whether FilePath exists, just put the path to Directory.Exists().
更多推荐
即使目录不存在,Directory Exists方法也返回true
发布评论