以下是脚本从网站下载zip文件的代码,但我会收到一个汇编错误,该错误指示"预期标识符"。
Public Class DownloadAddrFile
Public Function DownloadFile(ByVal Addr As String, ByVal SaveAddrFile As String) As Boolean
Try
Dim WC As New System.Net.WebClient()
WC.DownloadFile(Addr, SaveAddrFile)
Return True
Catch ex As Exception
MessageBox.Show(ex.Message)
Return False
End Try
End Function
End Class
Call DownloadFile("http://data.gdeltproject.org/events/index.html/20171002.export.CSV.zip", "C:UsersmwhitingDocumentsZip_filesdata.zip")
关于如何完成这项工作的任何帮助将是很棒的!
您无法在名称空间内调用方法。
创建一个类DownloadAddrFile
的实例,例如在按钮单击中调用方法DownloadFile
。(通常不需要Call
-键字)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim d As New DownloadAddrFile
d.DownloadFile("http://data.gdeltproject.org/events/index.html/20171002.export.CSV.zip", "C:UsersmwhitingDocumentsZip_filesdata.zip")
End Sub