网络浏览器过滤器
Web Browser Filter
我想要一个网站列表(每个网站在不同的行上),Web 浏览器将在导航时检查这些网站,如果它是当前的 url 则它将导航回来。下面是我目前创建的一些代码但失败了,因为它没有检查每一行文本,下面是一些代码也用当前文本检查文本。
Using sr As New StreamReader("website_lists.txt")
Dim lined As String
lined = sr.ReadToEnd()
Dim scanbox As New TextBox
scanbox.Multiline = True
Dim buff As StringBuilder = New StringBuilder
For Each line In lined
If TextBox1.Text.Contains(scanbox.Text) Then
webview.GoBack()
MsgBox("Infected website! For your own sake stay away!")
End If
Next
End Using
End Sub
一些类似的代码:
Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim f As FileStream = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
f = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
md5.ComputeHash(f)
Dim hash As Byte() = md5.Hash
Dim buff As StringBuilder = New StringBuilder
Dim hashByte As Byte
For Each hashByte In hash
buff.Append(String.Format("{0:X2}", hashByte))
Next
If scanbox.Text.Contains(buff.ToString) Then
有什么建议或帮助吗?提前致谢。
我建议 File.Readlines
...有关此方法的更多信息 here。另外,您声明了一个新的文本框,但从未设置文本,这意味着包含将无法工作...另一个建议,将 Option Strict 设置为您的朋友。
' Loop over lines in file.
For Each line As String In File.ReadLines("yourfile")
If TextBox1.Text.Contains(line) Then
webview.GoBack()
MsgBox("Infected website! For your own sake stay away!")
Exit For
End If
Next
我想要一个网站列表(每个网站在不同的行上),Web 浏览器将在导航时检查这些网站,如果它是当前的 url 则它将导航回来。下面是我目前创建的一些代码但失败了,因为它没有检查每一行文本,下面是一些代码也用当前文本检查文本。
Using sr As New StreamReader("website_lists.txt")
Dim lined As String
lined = sr.ReadToEnd()
Dim scanbox As New TextBox
scanbox.Multiline = True
Dim buff As StringBuilder = New StringBuilder
For Each line In lined
If TextBox1.Text.Contains(scanbox.Text) Then
webview.GoBack()
MsgBox("Infected website! For your own sake stay away!")
End If
Next
End Using
End Sub
一些类似的代码:
Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
Dim f As FileStream = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
f = New FileStream(ListBox1.SelectedItem, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
md5.ComputeHash(f)
Dim hash As Byte() = md5.Hash
Dim buff As StringBuilder = New StringBuilder
Dim hashByte As Byte
For Each hashByte In hash
buff.Append(String.Format("{0:X2}", hashByte))
Next
If scanbox.Text.Contains(buff.ToString) Then
有什么建议或帮助吗?提前致谢。
我建议 File.Readlines
...有关此方法的更多信息 here。另外,您声明了一个新的文本框,但从未设置文本,这意味着包含将无法工作...另一个建议,将 Option Strict 设置为您的朋友。
' Loop over lines in file.
For Each line As String In File.ReadLines("yourfile")
If TextBox1.Text.Contains(line) Then
webview.GoBack()
MsgBox("Infected website! For your own sake stay away!")
Exit For
End If
Next