locked
how to find corrupt file in vb.net RRS feed

Answers

  • Use quickpar first and save the recovery files forever. Otherwise, if you have the skills, write your own implementation of the Reed-Solomon Error Correction Code. Not for the inexperienced at all.

    Here or Here or Here

    If you are doubting the difficulty, imagine this: You receive a text file with the following contents:

    M83, a nearby spiral galaxy, has recently provided astronomers and scientists with exciting new information. The latest it has to offer is a detailed black hole named MQ1, which Australian astronomers found earlier this week. This small, yet super-powered black hole was spotted through the use of multiple telescopes, including the Hubble Space Telescope. Despite being considered "small", the 100 kilometers wide MQ1 black hole is more masskfsjh aiowrq;jrn098-7weuqjm dsfl;as;2319847jsa9)_&^9ome;dsad;
    [p\]13=2-90\23

    Without additional information, how would you know what the rest of the text should be ?

    Monday, March 3, 2014 1:52 AM

All replies

  • Use quickpar first and save the recovery files forever. Otherwise, if you have the skills, write your own implementation of the Reed-Solomon Error Correction Code. Not for the inexperienced at all.

    Here or Here or Here

    If you are doubting the difficulty, imagine this: You receive a text file with the following contents:

    M83, a nearby spiral galaxy, has recently provided astronomers and scientists with exciting new information. The latest it has to offer is a detailed black hole named MQ1, which Australian astronomers found earlier this week. This small, yet super-powered black hole was spotted through the use of multiple telescopes, including the Hubble Space Telescope. Despite being considered "small", the 100 kilometers wide MQ1 black hole is more masskfsjh aiowrq;jrn098-7weuqjm dsfl;as;2319847jsa9)_&^9ome;dsad;
    [p\]13=2-90\23

    Without additional information, how would you know what the rest of the text should be ?

    Monday, March 3, 2014 1:52 AM
  • how to find corrupt file in vb.net ?

    Get the hash of the known good file and compare that to the same file you think is corrupt. Without having a known good file to do a comparison then how would you expect to know a file is corrupt?

    Option Strict On
    
    Imports System.Security.Cryptography
    Imports System.IO
    Imports System.Text
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Me.CenterToScreen()
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim OFD As New OpenFileDialog
            OFD.InitialDirectory = "C:\Users\John\Desktop\Test Folder"
            OFD.Title = "Get MD5 Hash of file"
            OFD.Multiselect = False
            OFD.Filter = "Text File (*.Txt)|*.Txt"
            If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim MD5 = System.Security.Cryptography.MD5.Create
                Dim Hash As Byte()
                Dim sb As New System.Text.StringBuilder
                Using st As New IO.FileStream(OFD.FileName, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
                    Hash = MD5.ComputeHash(st)
                End Using
                For Each b In Hash
                    sb.Append(b.ToString("X2"))
                Next
                RichTextBox1.AppendText(OFD.FileName & " hash = " & vbCrLf & sb.ToString & vbCrLf & vbCrLf)
            End If
        End Sub
    
    End Class
    

    Text file = OrigFile.Txt

    This is a test.

    Text file = OrigFileCopied.Txt

    This is a test.

    Text file = OrigFileCopiedAndOneCharInTextChanged.Txt

    This is a tesx.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    • Proposed as answer by IronRazerz Monday, March 3, 2014 9:21 PM
    • Unproposed as answer by h_u_n_k Tuesday, March 4, 2014 3:56 AM
    • Proposed as answer by IronRazerz Tuesday, March 4, 2014 12:06 PM
    Monday, March 3, 2014 6:48 PM
  • thnk.

    but want to scan  computer for corrupt file and repair and del them .

    Tuesday, March 4, 2014 3:44 AM
  • thnk.

    but want to scan  computer for corrupt file and repair and del them .

    And what property is part of a file that all the sudden changes to "this file has been corrupted" once it becomes corrupt so that you can detect a file has become corrupted?

    There's no magic that can scan a computer and determine if a file has become corrupted. The only way to know is do some sort of comparison between what you believe is a corrupted file and the same file that is not corrupted. Is that really so difficult to understand?


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    Tuesday, March 4, 2014 3:56 AM
  • Corruptfile scanner , there are way to find

    Corrupt file and repair , want to find a way to do sam in vb.net thank.

     If whatever method you want to use exists and you have code examples in another programming language then post a link to the code so someone knows exactly what you want. If you don`t have any code examples but, you know exactly what you want to do then try google searching it and if this idea you have can be done the way you want to do it then there would be at least a few examples on the net somewhere.

    PS. We can`t understand you any better when you just repeat what you have already said and make it bold. That just appears like your yelling. People are less likely to help when you doing this.

    • Proposed as answer by Mr. Monkeyboy Tuesday, March 4, 2014 5:55 PM
    Tuesday, March 4, 2014 12:28 PM
  • Why would you want to scan a file, and then if it is corrupt, first fix it, then delete it ?

    Hopefully you mean repair OR delete ?????

    Tuesday, March 4, 2014 1:16 PM
  • Did you look at my first post ?

    It is not hard to see if a file is corrupt using a hash function. Repairing is another matter, you must have Error Correction Data or a backup. The most popular Error Correction is Reed-Solomon as I already stated.

    Tuesday, March 4, 2014 1:20 PM
  • Corruptfile scanner , there are way to find

    Corrupt file and repair , want to find a way to do sam in vb.net thank.

     If whatever method you want to use exists and you have code examples in another programming language then post a link to the code so someone knows exactly what you want. If you don`t have any code examples but, you know exactly what you want to do then try google searching it and if this idea you have can be done the way you want to do it then there would be at least a few examples on the net somewhere.

    PS. We can`t understand you any better when you just repeat what you have already said and make it bold. That just appears like your yelling. People are less likely to help when you doing this.

    It also makes the OP appear rather thick IMO.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    Tuesday, March 4, 2014 5:55 PM
  • Why would you want to scan a file, and then if it is corrupt, first fix it, then delete it ?

    Hopefully you mean repair OR delete ?????

    want to scan a file to find corrupt file

    is possible repair them or delete .

    Friday, March 14, 2014 2:46 PM
  • IT IS OBVIOUS HE WANTED TO SCAN THE DRIVE FOR ANY CORRUPTED FILE, WHAT WAS SO HARD ABOUT THE QUESTION TO UNDERSTAND?

    ANYWAYS TRY,

     For Each folder In IO.Directory.GetDirectories(ComboBox1.Text, "*.*", IO.SearchOption.AllDirectories)
                If folder = ComboBox1.Text & "System Volume Information" Then

                Else
                    For Each files In IO.Directory.GetFiles(ComboBox1.Text, "*.*", IO.SearchOption.AllDirectories)
                        Label1.Text = "Please wait..."
                        Application.DoEvents()
                        TOTAL += 1
                    Next
                    ProgressBar1.Maximum = TOTAL
                    For Each file In IO.Directory.GetFiles(ComboBox1.Text, "*.*", IO.SearchOption.AllDirectories)
                        Application.DoEvents()
                        Label1.Text = "Scanning:  " & file
                        m = New IO.StreamReader(file)
                        Try
                            m.ReadLine()
                            ProgressBar1.Value += 1
                            fi = CShort(FreeFile())
                            Try
                                FileOpen(fi, file, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
                                FileClose()
                
                        Catch ex As IO.IOException When ex.Message.Contains("The file or directory is corrupted and unreadable.") = True
                            corrupt += 1
                            ListView1.Items.Add(file & " is corrupt")
                        End Try

                    Next
                    Label1.Text = "Done: Corrupt Files=" & corrupt
                End If
            Next

    HUNK YOU WILL FIND MANY SITE AND FORUMS WERE YOU WILL FIND DUMB USER AND REALLY OTHER KIND OF USER WHO WILL TRY TO HELP , HOPE IT HELPED.



    • Proposed as answer by VB.N Saturday, March 12, 2016 3:23 PM
    • Edited by VB.N Saturday, March 12, 2016 3:25 PM
    • Unproposed as answer by Reed KimbleMVP Sunday, March 13, 2016 7:12 PM
    Saturday, March 12, 2016 3:22 PM
  • You do of course realize that the question was answered 2 years ago, right ?

    You do also realize that the sample code you posted will not compile, right ?

    You do also realize that the sample code you posted will NOT find corrupted files, even if it did compile. From the mess you posted, it appears to be looking for unreadable files, which is only a subset of corrupted files. Right ?



    Saturday, March 12, 2016 10:45 PM


  • thanks man it did  find unreadable file.

    • Edited by d-von Sunday, March 13, 2016 6:45 PM
    Sunday, March 13, 2016 5:02 PM
  • You do of course realize that the question was answered 2 years ago, right ?

    You do also realize that the sample code you posted will not compile, right ?

    You do also realize that the sample code you posted will NOT find corrupted files, even if it did compile. From the mess you posted, it appears to be looking for unreadable files, which is only a subset of corrupted files. Right ?



    was the question really answered ? no.

    do you know how to compile a undefined sample code ?

    doesnt seem so , atleast vb.n posted a sample code what was your contribution other than

    propose it as answered ?

    devon  dont be an ungratefull person that is an undefined sample code,

    first learn to complie an undefined sample code  , rather than copy paste the code .

    and it did find unreadable file.


    Sunday, March 13, 2016 6:56 PM