powershell 判断是目录还是文件

2025-04-07 17:42:39
推荐回答(1个)
回答1:

# 目录存在
Test-Path $path -PathType Container
[System.IO.Directory]::Exists($path)

# 文件存在
Test-Path $path -PathType Leaf
[system.IO.File]::Exists($path)