Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Why WebClient DownloadComplete Event is not executed

$
0
0

$webClient = New-Object System.Net.WebClient
    $Global:downloadComplete = $False
    Register-ObjectEvent $webclient DownloadFileCompleted `
      -SourceIdentifier WebClient.DownloadFileComplete `
      -Action {$Global:downloadComplete = $true}
    $source="http://XXXX\1.zip"
    "Source Address is {0}  " -f $source
    $dest = "C:\windows.zip
    $webClient.DownloadFile($source,$dest)

   "the value of downloadComplete is {0}" -f $downloadComplete

why the DownloadComplete Event is not executed value of the download complete is still "Failse" ?


Best Regards, Mike


Viewing all articles
Browse latest Browse all 21975

Trending Articles