【发布时间】:2017-08-19 13:39:03
【问题描述】:
当我的文件系统观察程序检测到病毒时,会显示一个对话框,但是当我单击删除文件选项时,它说它在我的程序中打开但在文件系统观察程序中,当我添加 openfiledialog.Dispose 函数时,它不会显示我的对话框,所以这是代码somone可以提供修复吗?代码如下。
Private Sub FileSystemWatcher1_Changed(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Changed
Try
Detect.Labellastreal.Text = e.FullPath
ListBox3.Items.Add(Detect.Labellastreal.Text)
Me.OpenFileDialog3.FileName = ""
Dim scanbox As New TextBox
scanbox.Text = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\VirusList.dat").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)
md5.ComputeHash(f)
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))
Next
f.Close()
If scanbox.Text.Contains(buff.ToString) Then
Me.OpenFileDialog3.FileName = e.FullPath
Detect.ShowDialog()
WriteToLog("Virus detected")
End If
Catch exception1 As Exception
ProjectData.SetProjectError(exception1)
Dim ex As Exception = exception1
ProjectData.ClearProjectError()
End Try
End Sub
【问题讨论】:
-
我第一次发帖时所有的布局都错了......来自私人子是代码的开始抱歉
-
你正在创建两个
FileStreams,立即放弃第一个。 -
那么我该如何修复我的代码?
-
谢谢你的回复顺便说一句
-
在需要时不要打开两个文件流。