Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your purpose is to compare 2 files to see if the contents are the same, without regards to the information about the file (ie, modified date, name, type, etc.) you should use a hash on both the files. Here is some code I have used for a while. There are many ways to do this.</p> <pre><code>''' &lt;summary&gt; ''' Method to get a unique string to idenify the contents of a file. ''' Works on any type of file but may be slow on files 1 GB or more and large files across the network. ''' &lt;/summary&gt; ''' &lt;param name="FI"&gt;System.IO.FileInfo for the file you want to process&lt;/param&gt; ''' &lt;returns&gt;String around 50 characters long (exact length varies)&lt;/returns&gt; ''' &lt;remarks&gt;A change in even 1 byte of the file will cause the string to vary ''' drastically so you cannot use this to see how much it differs by.&lt;/remarks&gt; Public Shared Function GetContentHash(ByVal FI As System.IO.FileInfo) As String Dim SHA As New System.Security.Cryptography.SHA512Managed() Dim sBuilder As System.Text.StringBuilder Dim data As Byte() Dim i As Integer Using fs As New IO.FileStream(FI.FullName, IO.FileMode.Open) data = SHA.ComputeHash(fs) fs.Flush() fs.Close() End Using sBuilder = New System.Text.StringBuilder ' Loop through each byte of the hashed data ' and format each one as a hexadecimal string. For i = 0 To data.Length - 1 sBuilder.Append(data(i).ToString("x2")) Next i Return sBuilder.ToString() End Function </code></pre> <p>You need to run this on each file, to come up with a string that uniquely identifies the file, then compare the 2 strings.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload