In memory file compare

OSVBNET 1,386 Reputation points
2022-07-01T10:24:46.163+00:00

Hello,
I have a file stored in my app as a resource: My.Resources.blah.blah
Need to compare it against a file on disk without writing it to disk (WriteAllBytes) in memory to check if both files are identical or difference (like FC.exe)
In short: 1st file is in resources, 2nd file on disk, compare them without saving the 1st file.
Any built-in method in .NET or if not what's the suggestion?
Thanks all :)

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,580 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,831 Reputation points
    2022-07-01T10:44:50.853+00:00

    You can compare Bytes Arrays of the 2 files
    Something like :

            Dim byteFileResources As Byte() = My.Resources.YourFile  
            Dim sFile = "E:\YourFile.exe"  
            Dim byteFile As Byte() = File.ReadAllBytes(sFile)  
            Dim bRet = StructuralComparisons.StructuralEqualityComparer.Equals(byteFileResources, byteFile)
    
    0 comments No comments

0 additional answers

Sort by: Most helpful