Visual C# Developer Center > Visual C# Forums > Visual C# General > finding the binary code of a .wav file
Ask a questionAsk a question
 

Answerfinding the binary code of a .wav file

  • Friday, November 06, 2009 9:10 AMsap19 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi
    I'm working on a project where i have a few .wav files and i need to compare their context.in order to do that, i thought i should find the binary code for each of the .wav files and compare the codes to each other,but i don't know how to find the binary code...
    do you know how to do that?
    tnx in advance!

Answers

  • Friday, November 06, 2009 12:56 PMDavid M MortonMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hmmm... not sure what you mean by comparing context. Perhaps you mean comparing content?

    There's two ways:

    1.  Use WinDiff.
    2.  Use File.ReadAllBytes to get the bytes of each file, then loop through them to make sure they're the same.

    public static bool FilesAreEqual(string filename1, string filename2)
    {
        byte[] firstFile = File.ReadAllBytes(filename1);
        byte[] secondFile = File.ReadAllBytes(filename2);

        // if the lengths don't match, the contents don't match.
        if (firstFile.Length != secondFile.Length)
            return false;

        for (int i = 0; i < firstFile.Length; i++)
            if (firstFile[i] != secondFile[i])
                return false;
     
        return true;
    }
    Coding Light - Illuminated Ideas and Algorithms in Software
    Coding Light WikiLinkedInForumsBrowser

All Replies

  • Friday, November 06, 2009 12:56 PMDavid M MortonMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hmmm... not sure what you mean by comparing context. Perhaps you mean comparing content?

    There's two ways:

    1.  Use WinDiff.
    2.  Use File.ReadAllBytes to get the bytes of each file, then loop through them to make sure they're the same.

    public static bool FilesAreEqual(string filename1, string filename2)
    {
        byte[] firstFile = File.ReadAllBytes(filename1);
        byte[] secondFile = File.ReadAllBytes(filename2);

        // if the lengths don't match, the contents don't match.
        if (firstFile.Length != secondFile.Length)
            return false;

        for (int i = 0; i < firstFile.Length; i++)
            if (firstFile[i] != secondFile[i])
                return false;
     
        return true;
    }
    Coding Light - Illuminated Ideas and Algorithms in Software
    Coding Light WikiLinkedInForumsBrowser