这是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)
这可能吗?