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 4 6493
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]
- mv*@spam.guard. caspershouse.co m
"Nikos" <nk******@freem ail.gr> wrote in message
news:%2******** ********@TK2MSF TNGP09.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
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP10.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] - mv*@spam.guard. caspershouse.co m
"Nikos" <nk******@freem ail.gr> wrote in message news:%2******** ********@TK2MSF TNGP09.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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Nikos" <nk******@freem ail.gr> wrote in message
news:uv******** *****@TK2MSFTNG P12.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]" <mv*@spam.guard .caspershouse.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.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] - mv*@spam.guard. caspershouse.co m
"Nikos" <nk******@freem ail.gr> wrote in message news:%2******** ********@TK2MSF TNGP09.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... 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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike Austin |
last post by:
It's the most annoying thing, and causes hours of frustration. Why can't it
be resolved?
Regards,
Mike Austin
Example:
#include <iostream>
#include <string>
|
by: Tarique Jawed |
last post by:
Alright I needed some help regarding a removal of a binary search
tree. Yes its for a class, and yes I have tried working on it on my
own, so no patronizing please. I have most of the code working, even
the removal, I just don't know how to keep track of the parent, so
that I can set its child to the child of the node to be removed.
IE - if I had
C
/ \
B D
|
by: Thomas Scheiderich |
last post by:
The following code works fine. It opens file reads the data and then
closes.
****************************************************************************
****************
Dim objFileInfo As FileInfo = new FileInfo(strFilePath)
Dim objStream as StreamReader = objFileInfo.OpenText()
Dim strContents as String = objStream.ReadToEnd()
objStream.Close()
****************************************************************************
|
by: Nikos |
last post by:
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
|
by: Andrew |
last post by:
Hi, im trying to create a small function which can create a binary tree
from the entries in a text file and after that we can perform all the
usual operations like search, insert and delete etc. Now i have entries
something like this
IPaddress Phone No
192.168.2.1 2223447689
192.168.2.2 3334449898
192.168.2.3 5667869089
| |
by: Antoine De Groote |
last post by:
Hi there,
I have a word document containing pictures and text. This documents
holds several 'ABCDEF' strings which serve as a placeholder for names.
Now I want to replace these occurences with names in a list (members). I
open both input and output file in binary mode and do the
transformation. However, I can't open the resulting file, Word just
telling that there was an error. Does anybody what I am doing wrong?
Oh, and is this...
|
by: Rudi Menter |
last post by:
Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?
Thx,
Regards
--
|
by: hn.ft.pris |
last post by:
I have the following code:
Tree.h defines a simple binary search tree node structure
########## FILE Tree.h ################
#ifndef TREE_H
#define TREE_H
//using namespace std;
template <typename Tclass Tree{
private:
Tree<T*left;
|
by: Hunk |
last post by:
Hi
I have a binary file which contains records sorted by Identifiers
which are strings. The Identifiers are stored in ascending order. I
would have to write a routine to give the record given the Identifier.
The logical way would be to read the record once and put it in an STL
container such as vector and then use lower_bound to search for a
given identifier. But for some strange reason i'm asked to not use a
container but instead...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |