以下是从网站下载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:\Users\mwhiting\Documents\Zip_files\data.zip")
任何有关如何完成这项工作的帮助都会很棒!
答案 0 :(得分:2)
您无法在Namespace内调用方法。
创建类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:\Users\mwhiting\Documents\Zip_files\data.zip")
End Sub