首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >测试路径-Leaf意义

测试路径-Leaf意义
EN

Stack Overflow用户
提问于 2018-01-15 11:44:49
回答 3查看 10.8K关注 0票数 2

我正在学习PowerShell,并在Technet上看到了这样的用法:

代码语言:javascript
复制
Test-Path -Path $DirectoryPath -PathType 'Leaf'

路径类型Leaf的含义是什么?

很清楚ContainerAny路径类型是什么。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-01-15 11:50:27

来自Test-Path帮助:

代码语言:javascript
复制
-PathType <TestPathType>
    Specifies the type of the final element in the path. This cmdlet returns $True if the element is of the specified
    type and $False if it is not. The acceptable values for this parameter are:

    - Container. An element that contains other elements, such as a directory or registry key. - Leaf. An element that
    does not contain other elements, such as a file. - Any. Either a container or a leaf. Tells whether the final
    element in the path is of a particular type.

具体地说:

-Leaf。不包含其他元素(如文件)的元素。

从控制台获取这些信息的最简单方法是Get-Help Test-Path -Parameter PathType

票数 3
EN

Stack Overflow用户

发布于 2018-01-15 11:53:36

如果您看到相同的PowerShell文档,这将是明确的。使用以下命令

Get-Help Test-Path -Full

如果您查看Test-Path支持的所有参数的描述,您将看到-PathType参数,该参数如下

代码语言:javascript
复制
 -PathType <TestPathType>
 Specifies the type of the final element in the path. This cmdlet returns $True if the element is of the
 specified type and $False if it is not. The acceptable values for this parameter are:

 - Container. An element that contains other elements, such as a directory or registry key. - Leaf. An element
 that does not contain other elements, such as a file. - Any. Either a container or a leaf. Tells whether the
 final element in the path is of a particular type.

 Required?                    false
 Position?                    named
 Default value                None
 Accept pipeline input?       False
 Accept wildcard characters?  false

因此,-container是指目录、文件夹或子文件夹,而leaf是指文件.如果需要更多帮助,也可以使用Get-Help Test-Path -Examples查看示例

票数 3
EN

Stack Overflow用户

发布于 2021-08-30 22:11:52

一般来说:

  • Leaf:文件
  • Container:文件夹/目录
  • Any:文件或文件夹

隐喻是,您的文件系统就像一个树层次结构,每个分支节点要么能够进一步分支(文件夹),要么是一个不能进一步分支的叶节点(文件)。

举例说明:

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48262339

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档