Buonasera a tutti,
ho creato un piccolo programma per il download di un archivio zippato da un sito web:
Private Sub ImportaTafMis()
Dim ModuloChiamante = FrmMenu.frmChiamante
dim sigla as string = "OR"
Dim readText() As String = File.ReadAllLines(Application.StartupPath & "\Preferenze.tfm")
Dim CartArchDIS As String = readText(1)
Dim LinkTAF As String = "https://www1.agenziaentrate.gov.it/servizi/TafDis/download.php?&tipofile={0}&iduff={1}1"
Dim LinkM = String.Format(LinkTAF, "DIST", sigla)
Dim misurate As New WebClient()
AddHandler misurate.DownloadProgressChanged, AddressOf ShowDownloadProgressMis
AddHandler misurate.DownloadFileCompleted, AddressOf OnDownloadCompleteMis
misurate.DownloadFileAsync(New Uri(LinkM), CartArchDIS & "/Dist.zip")
End Sub
Private Sub OnDownloadCompleteMis(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
If Not e.Cancelled AndAlso e.Error Is Nothing Then
Dim CartArchDIS As String
Dim readText() As String = File.ReadAllLines(Application.StartupPath & "\Preferenze.tfm")
CartArchDIS = readText(1)
ZipFile.ExtractToDirectory(CartArchDIS & "dist.zip", CartArchDIS)
My.Computer.FileSystem.DeleteFile(CartArchDIS & "dist.zip", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
Else
MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Download archivi Misurate")
BtuEsci.Enabled = True
End If
End Sub
Private Sub ShowDownloadProgressMis(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
ProgressBarMis.Value = e.ProgressPercentage
LblPerMis.Text = e.ProgressPercentage & "%"
Dim totbyte = e.TotalBytesToReceive
End Sub
Il codice sopra ha sempre funzionato, ma ultimamente segnala il seguente errore:
"Richiesta annullata: Impossibile creare un canale sicuro SSL/TLS".
E' possibile che sia dovuto alla rete internet troppo carica? O sbaglio qualcosa nel codice.
Grazie