Answer» Hello,
I would LIKE to know if anybody could help , I am trying to read the binary content of a file and search for a specific hex code, here is what I have:
Dim gett As New IO.BinaryReader(IO.File.OpenRead("c:\file.txt")) Dim read As String = gett.ReadDouble Dim SearchString As String MessageBox.Show(read) SearchString = ("4D5A50000200000004") If read.IndexOf(SearchString) <> -1 Then MessageBox.Show("found") Else MessageBox.Show("no")
Thanks in Advance
Al968I'm not sure what the question is. Is this working or not and if not where is the problem?
The ReadDouble method reads an 8-byte floating point value from the current stream and advances the current position of the stream by EIGHT bytes. I may be wrong, but your search argument seems too large and probably shouldn't be dimensioned as a string.
8-)
PS. I got the definition of ReadDouble direct from the VB.Net help. MARVELOUS little invention that help thing.N/o the code I posted is not working Yes I do know that "little invention" Yes the "double" part is a mistake but Then I don't know what to read it as :-/
Thanks
Al968Check out the ReadAllBytes method. I'm still not certain your search argument is defined properly or even that you need a binary reader for a text file.
I'm very confused, your file has a txt extension. Can you not simply use the ReadAllLines method and then use Instr to search for your argument. :-?ACTUALLY the file.txt is not the actual file I want to read it from, the file is an exe file, Sorry if I confused you :-/
Thanks
Al968
|