相关疑难解决方法(0)

powershell 2.0尝试捕获如何访问异常

这是try catchPowerShell 2.0中的内容

$urls = "http://www.google.com", "http://none.greenjump.nl", "http://www.nu.nl"
$wc = New-Object System.Net.WebClient 

foreach($url in $urls)
{
    try
    {
        $url
        $result=$wc.DownloadString($url)
    }
    catch [System.Net.WebException]
    {
        [void]$fails.Add("url webfailed $url")
    }  
}
Run Code Online (Sandbox Code Playgroud)

但我想要做的就是在c#中

catch( WebException ex)
{
    Log(ex.ToString());
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

powershell try-catch

127
推荐指数
1
解决办法
10万
查看次数

标签 统计

powershell ×1

try-catch ×1