I have an anti-virus in Visual Basic .Net.

I want to have a real-time protection engine in my program, but I'm having some issues with the code I'm using now, which is this:

Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed

            labellastreal.Text = e.FullPath
            Me.OpenFileDialog1.FileName = ""
            Dim scanbox As New TextBox
            scanbox.Text = My.Computer.FileSystem.ReadAllText("viruslist.txt").ToString
            Dim md5 As New MD5CryptoServiceProvider
            Dim f As New FileStream(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read, &H2000)
            f = New FileStream(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read, &H2000)
            Dim hash As Byte() = md5.Hash
            Dim buff As New StringBuilder
            Dim hashByte As Byte
            For Each hashByte In hash
                buff.Append(String.Format("{0:X2}", hashByte))
            If scanbox.Text.Contains(buff.ToString) Then
                Me.OpenFileDialog1.FileName = e.FullPath

            End If

        Catch exception1 As Exception
            Dim ex As Exception = exception1
        End Try

    End Sub

The problem with this code, is that my Form2 (which is the Form that says 'virus detected') isn't showing up.

Is there something wrong with my code?


While I think you are at least trying you left out all the other exploits in the wild. That is this would not catch web sites that mine coins and well that list of things that are considered exploits don't always involve files.

Maybe you should consider open source next time? https://windowsreport.com/open-source-antivirus/