我是 Powershell 的新手,我想检查 Android 模拟器中是否存在特定路径,我需要在 PowerShell 中使用它。我尝试打印结果adb shell ls /data/local/tmp/
,它会列出文件,如果路径不存在,它会显示没有这样的文件,但是如何检测呢?有谁知道?
其实我已经找到了检查它的方法
$checkPathExists = (adb shell ls $pathToCheck) | Out-String
if($checkPathExists -match 'No such file or directory')
{
Write-Host "$pathToCheck path does not exist. Try to create it ..." -ForegroundColor Red
adb shell mkdir $pathToCheck
if(!$?)
{
Write-Host "Creating $pathToCheck folder failed!" -ForegroundColor Red
exit 1
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句