Click here to Skip to main content
11,642,216 members (61,338 online)
Click here to Skip to main content

Tagged as

File Data Inspector

, 2 Apr 2012 CPOL 4.5K 41 1
Rate this:
Please Sign up or sign in to vote.
Simply search data in file


This is just a simple utility to search data in a file.

It may be useful to inspect data inside a file.

Using the Code

This piece of code I found around on the web shows how to find an array of bytes inside another one:

public static int IndexOfBytes(byte[] array, byte[] pattern, int startIndex, int count)
    int i = startIndex;
    int endIndex = count > 0 ? startIndex + count : array.Length;
    int fidx = 0;

    while (i < endIndex)
        fidx = (array[i] == pattern[fidx]) ? ++fidx : 0;
        if (fidx == pattern.Length)
            return i - fidx + 1;
    return -1;

This is the number conversion in the bytes routine, according to the format selected (8, 16, 32, or 64 bit):

switch (numberBase)
    case 8:
        byte2Find = new byte[] { byte.Parse(textBoxNumber.Text) };
    case 16:
        byte2Find = BitConverter.GetBytes(Convert.ToInt16(textBoxNumber.Text));
    case 32:
        byte2Find = BitConverter.GetBytes(Convert.ToInt32(textBoxNumber.Text));
    case 64:
        byte2Find = BitConverter.GetBytes(Convert.ToInt64(textBoxNumber.Text));
        byte2Find = new byte[0];


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Fabrizio Stellato
Software Developer (Senior)
Italy Italy
Creator of:
Impulse Media Player
Audio Pitch & Shift
Ultimate Music Tagger
Modern Log Viewer
Pitch Tuner
Modern Audio Tagger

You may also be interested in...

Comments and Discussions

BugSorry, but your code is wrong Pin
Andreas Kroll2-Apr-12 11:50
memberAndreas Kroll2-Apr-12 11:50 
GeneralRe: Sorry, but your code is wrong Pin
Manfred R. Bihy2-Apr-12 21:42
mvpManfred R. Bihy2-Apr-12 21:42 
GeneralRe: Sorry, but your code is wrong Pin
Fabrizio Stellato2-Apr-12 21:54
memberFabrizio Stellato2-Apr-12 21:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150731.1 | Last Updated 2 Apr 2012
Article Copyright 2012 by Fabrizio Stellato
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid