|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
open binary file and search hex stringHi... I would like to search for a hex string (for example: "E903") inside a
binary file... Although I open the file correctly, how do I search hex values? Thanks in advance! Nikos Nikos,
Are you looking for the character string "E903" or for the two-byte value 59651? Either way, once you know what bytes you are looking for, you need to open the file with a FileStream, and cycle through all of the bytes, looking one-by-one for a match. Hope this helps. -- Show quoteHide quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Nikos" <nkour***@freemail.gr> wrote in message news:%23zJV0h5OFHA.1528@TK2MSFTNGP09.phx.gbl... > Hi... I would like to search for a hex string (for example: "E903") inside > a binary file... > Although I open the file correctly, how do I search hex values? > Thanks in advance! > Nikos > > > Thanks for the reply... I am actually looking for character string "E903"...
I am stuck with the search routine. How to search hex values? Should I load all file contents to an array and search? Or, is it possible to just read the file byte after byte and examine the offset of the search string? Nikos Show quoteHide quote "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in message news:%23OV9UB6OFHA.1396@TK2MSFTNGP10.phx.gbl... > Nikos, > > Are you looking for the character string "E903" or for the two-byte > value 59651? Either way, once you know what bytes you are looking for, > you need to open the file with a FileStream, and cycle through all of the > bytes, looking one-by-one for a match. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > "Nikos" <nkour***@freemail.gr> wrote in message > news:%23zJV0h5OFHA.1528@TK2MSFTNGP09.phx.gbl... >> Hi... I would like to search for a hex string (for example: "E903") >> inside a binary file... >> Although I open the file correctly, how do I search hex values? >> Thanks in advance! >> Nikos >> >> >> > > Nikos,
I would just read the file byte by byte, keeping a buffer of the last n bytes read, where n is the length of the bytes you want to search for. If you are looking for that character string, then you should use the GetBytes method on the AsciiEncoder class in the System.Text namespace to get the bytes that the string actually is comprised of. -- Show quoteHide quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Nikos" <nkour***@freemail.gr> wrote in message news:uvJzQQ6OFHA.244@TK2MSFTNGP12.phx.gbl... > Thanks for the reply... I am actually looking for character string > "E903"... > I am stuck with the search routine. How to search hex values? > Should I load all file contents to an array and search? Or, is it > possible to just read the file byte after byte and examine the offset of > the search string? > Nikos > > > > "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote > in message news:%23OV9UB6OFHA.1396@TK2MSFTNGP10.phx.gbl... >> Nikos, >> >> Are you looking for the character string "E903" or for the two-byte >> value 59651? Either way, once you know what bytes you are looking for, >> you need to open the file with a FileStream, and cycle through all of the >> bytes, looking one-by-one for a match. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mvp@spam.guard.caspershouse.com >> >> "Nikos" <nkour***@freemail.gr> wrote in message >> news:%23zJV0h5OFHA.1528@TK2MSFTNGP09.phx.gbl... >>> Hi... I would like to search for a hex string (for example: "E903") >>> inside a binary file... >>> Although I open the file correctly, how do I search hex values? >>> Thanks in advance! >>> Nikos >>> >>> >>> >> >> > > Thanks... I 'll check it now...
Show quoteHide quote > Nikos, > > I would just read the file byte by byte, keeping a buffer of the last n > bytes read, where n is the length of the bytes you want to search for. If > you are looking for that character string, then you should use the > GetBytes method on the AsciiEncoder class in the System.Text namespace to > get the bytes that the string actually is comprised of. > >
DataReader in Excel (Better Post than the last)
Update for VS .NET 2003? Help with some code? for loop ending condition Compiler errors due to temp file inconsistencies ?? Remove items from listbox How to use Regex to Parse this String Problems with the excel find function in vb.net newbie question regarding repeater control ASP.net speech |
|||||||||||||||||||||||