Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 需要VB读取txt文件或任何其他文件并执行特定操作_Vb.net_Testing_Blocking - Fatal编程技术网

Vb.net 需要VB读取txt文件或任何其他文件并执行特定操作

Vb.net 需要VB读取txt文件或任何其他文件并执行特定操作,vb.net,testing,blocking,Vb.net,Testing,Blocking,所以我正在为我自己的家庭建立一个屏蔽程序 假设我有一个txt文件,列出了这些网站: www.notarealwebsite.com www.fake.net 我想让它找到包含这些信息的txt文件,然后拉它并使用它,因为我的程序是一个web浏览器,我想让它阻止我定义的那些网站 我只想让它在我的应用程序中屏蔽网站,而不是在整个计算机上屏蔽网站(意思是我不想让它在Chrome、Firefox、Internet Explorer、Safari等浏览器中被屏蔽)“blocked.txt”:每行一个站点 它

所以我正在为我自己的家庭建立一个屏蔽程序

假设我有一个txt文件,列出了这些网站: www.notarealwebsite.com www.fake.net

我想让它找到包含这些信息的txt文件,然后拉它并使用它,因为我的程序是一个web浏览器,我想让它阻止我定义的那些网站

我只想让它在我的应用程序中屏蔽网站,而不是在整个计算机上屏蔽网站(意思是我不想让它在Chrome、Firefox、Internet Explorer、Safari等浏览器中被屏蔽)

“blocked.txt”:每行一个站点

它还没有准备好直接使用,因为可以通过输入“somesite.com/”而不是被阻止的“somesite.com”轻松绕过它

但它应该给你一个想法

    Dim urlBlocked As Boolean = False ''The ugly way...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    For Each line As String In System.IO.File.ReadAllLines("blocked.txt")
        If TextBox1.Text = line Then
            urlBlocked = True
            MsgBox("Action Blocked!")
        Else
            If Not urlBlocked Then
                WebBrowser1.Navigate(TextBox1.Text)
            End If
        End If
    Next
    urlBlocked = False
End Sub

我已经有一段时间没有读过这篇文章了。我已经成为一个更有经验的程序员了,谢谢。我已经弄明白了<代码>黑名单:http://blockedwebsite.com/* http://www.blockedwebsite.com/* http://blockedwebsite.com http://www.blockedwebsite.com