0

我的目标是保存用户当前所在的网页,但出现错误。这是我的代码:

Dim C As String = "C:\"
Dim website As String = WebBrowser1.Url 'errors here!
Dim LocalFilePath As String = C + website
Dim objWebClient As New System.Net.WebClient
objWebClient.DownloadFile(website, LocalFilePath)

错误是它不会让我将该 URL 塞入我的字符串变量中。

4

1 回答 1

1

WebBrowser1.Url返回Uri类型的对象,而不是字符串。您正在尝试将 Uri 分配给字符串,因此要么将其转换为字符串,要么更改website为 type Uri

Dim website As String = WebBrowser1.Url.ToString()

或者

Dim website As Uri = WebBrowser1.Url
于 2013-01-30T23:25:10.233 回答