Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I have asked this question but still need some help to change listbox1.selected item to DirTree1.selectedNode
 
I get an exception when trying to do this and need to know where im going wrong.
 
any explaination to this would be appricated... thank you in advance Smile | :)
 
The code I have so far is:
 
Try
Using scanbox As New TextBox()
 Dim read As String = My.Computer.FileSystem.ReadAllText("virusSig.txt")
 ProgressBar1.Increment(1)
 detected.Text = Conversions.ToString(CheckedListBox1.Items.Count)
 files.Text = Conversions.ToString(ProgressBar1.Value)
 scanbox.Text = read.ToString
    Using 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
                        CheckedListBox1.Items.Add(ListBox1.SelectedItem)
                        End If
                    End Using
                End Using
            Catch ex As Exception
            End Try
 
What am I missing or what do I need to do so that my (virusSig.txt) will open and check md5 hash with Dirtree1? I have tried many things to get this to work but am still in the dark.
 
thank you in advance Smile | :)
Posted 16-Feb-11 21:49pm
Dale 20121.8K
Edited 16-Feb-11 22:01pm
(no name)17.1K
v2
Comments
Sunasara Imdadhusen at 17-Feb-11 7:23am
   
What is error?
Dale Seeley at 17-Feb-11 14:21pm
   
there is no imediate error but I need to replace ListBox1.SelectedItem to DirTree1.selectednode......
 
As it is the code opens the item being scanned in a listbox and I need it to open the item as treeview if that makes any sense.... Im not sure how to ask
Dale Seeley at 17-Feb-11 14:43pm
   
Ok I have tried to change the code above to use my VirusSig.txt to MD5 hash check when the user selects a root node in my treeview but nothing seems to be happening and no virus is found even thoe I have downloaded one straight to my desktop for testing purposes.
 
Here is the code after I have changed it:
 

Try
Using scanbox As New TextBox()
Dim read As String = My.Computer.FileSystem.ReadAllText("virusSig.txt")
detected.Text = Conversions.ToString(CheckedListBox1.Items.Count)
scanbox.Text = read.ToString
Using md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider()
Dim f As FileStream = New FileStream(DirTree1.SelectedNode.ToString, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
f = New FileStream(DirTree1.SelectedNode.ToString, 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
CheckedListBox1.Items.Add(DirTree1.SelectedNode.ToString)
End If
End Using
End Using
Catch ex As Exception
End Try
End Sub

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 274
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 PIEBALDconsult 200
4 BillWoodruff 174
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 17 Feb 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100