Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

StreamReader reading only the 1st line of a .txt file?


  • Please log in to reply
2 replies to this topic

#1 Ivann700

Ivann700

  • Members
  • 50 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Slanec, Kosice-okolie, Slovakia
  • Local time:03:02 AM

Posted 15 May 2018 - 10:55 AM

Lets get straight to it. I have got this:


    Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim path As String = OpenFileDialog1.FileName
            txtFilePath.Text = path

            Dim sample As String
            sample = md5_hash(path)
            txtHash.Text = md5_hash(path)

            Using f As System.IO.FileStream = System.IO.File.OpenRead("md5.txt")
                Using s As System.IO.StreamReader = New System.IO.StreamReader(f)
                    While Not s.EndOfStream
                        Dim line As String = s.ReadLine

                        If (line = sample) Then
                            lblResult.Text = "Infected!"
                            lblResult.ForeColor = Color.Red
                        Else
                            lblResult.Text = "Clean!"
                            lblResult.ForeColor = Color.Green
                        End If
                    End While
                End Using
            End Using
        End If
    End Sub

So it reads hashes from md5.txt (its a scanner but dont blame me for using MD5) and it doesnt detect all on the list. It detects only the first hash in md5.txt as "Infected". Can somebody give a tip how to fix this?


Edited by Ivann700, 15 May 2018 - 10:57 AM.

Bananas never lose...
 



OS: Windows 7 Ultimate x64, AntiVirus: ESET NOD32, Firewall: Nothing lol, PC: Fujitsu Esprimo P5731, CPU: Intel Core 2 Duo E7500
Mobo: Fujitsu D3011-A1, RAM: DDR3 4GB @ 666 MHz (But really), Storage: Seagate Barracuda 80 GB 7K RPM SATA II + WD Blue 1 TB SATA III
GPU: nVidia GT710 2 GB @ 1251 MHz, Sound: That ricer, stuff, PSU: 300W OEM, Case: Fujitsu P5731


BC AdBot (Login to Remove)

 


#2 hamluis

hamluis

    Moderator


  • Moderator
  • 56,299 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Killeen, TX
  • Local time:08:02 PM

Posted 15 May 2018 - 01:04 PM

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/fbcbbbf1-71e0-4b08-b424-f386fb59f790/need-help-making-streamreader-read-from-the-top-to-bottom-lines-in-a-text-file?forum=vbgeneral

 

Louis



#3 Ivann700

Ivann700
  • Topic Starter

  • Members
  • 50 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Slanec, Kosice-okolie, Slovakia
  • Local time:03:02 AM

Posted 15 May 2018 - 01:06 PM

OK, thanks.


Bananas never lose...
 



OS: Windows 7 Ultimate x64, AntiVirus: ESET NOD32, Firewall: Nothing lol, PC: Fujitsu Esprimo P5731, CPU: Intel Core 2 Duo E7500
Mobo: Fujitsu D3011-A1, RAM: DDR3 4GB @ 666 MHz (But really), Storage: Seagate Barracuda 80 GB 7K RPM SATA II + WD Blue 1 TB SATA III
GPU: nVidia GT710 2 GB @ 1251 MHz, Sound: That ricer, stuff, PSU: 300W OEM, Case: Fujitsu P5731





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users