powershell判断是文件夹还是文件

2025-05-10 21:53:08
推荐回答(1个)
回答1:


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

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