2
現在、Imは処理中に例外を検出してユーザーに「分かりやすい」エラーメッセージを表示する視覚的エラーGUIをプログラミングしています。しかし、Get-ChildItem
コマンドレットを使用している間は例外を検出できないようです。 try/catch以外の方法を使用する必要がありますか?PowerShell Get-ChildItem catchの方法例外
ここでPowerShellのスクリプトは次のとおりです。
if ($checkBox1.Checked) {
Try{
Get-ChildItem -path K:\adm_spm_logdb_data\ADP\DATA |Rename-Item -newname { $($_.BaseName -split '_provide')[0] + $_.Extension };
}catch [System.Exception]{
$listBox1.Items.Add("An error occured while trying to process ADP-Files please check the manual!")
}
$listBox1.Items.Add("Please check your System files to ensure the process has finished")
}
私はDriveNotFoundException
、その結果、偽-path
を使用して例外を作成しようとしました。でもtry/catchを使って捕まえられないようです。
は、それが働いたありがとう!私はできるだけ早くこの答えを受け入れます。 –