Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How to detect a string in a binary file?


2 replies to this topic

EberhardH

EberhardH
  • Members
  • 137 posts

Posted 21 March 2002 - 15:49

Hi,

I've got to check if an old version of a file contains a certain string, let's say "(G+)", anywhere in it. This is the only way to identify this file.

FileGrep() does not work with binary files.

So I tried to use StrFind(). But it expects a string as argument. In a while loop, ReadBytes() always reads 60,000 bytes into a string (I also tried with only 600 bytes). The string still contains the hexadec. bytes.

The result: StrFind() is unable to detect the pattern. It only works with pure ASCII strings.

It is hard to imagine that I can read bytes, write bytes, seek a pointer - but cannot check if a binary file does contain a pattern.

Any idea?

Eberhard

Ide Nentjes

Ide Nentjes
  • Members
  • 222 posts

Posted 21 March 2002 - 17:56

Hi EberhardH

I'd say you best shot is using ReadBytes to stream though the binary file, and analyzing the String that this function yield.
Read up in ReadBytes in the online help for more info.

HtH, Ide

EberhardH

EberhardH
  • Members
  • 137 posts

Posted 22 March 2002 - 13:14

Hi Ide,

thanks for your answer.

The problem is: it really takes ages to browse through a file of about 800 KB, always reading if the wanted pattern is there or not ...

Eberhard