Deleting a block of text from binary file with a header

  • Thread starter Thread starter showson1
  • Start date Start date
S

showson1

Hi all.
We have some files that are basically TIF images with a text header.
The header portion is blocked by {startdb} and {enddb}.. it is the
same format for all the files.

What I need to do is read the file in, delete that block (including
the startdb and enddb) and write out the result as a TIF.
I can manually do this by loading them in a HEX editor, deleting the
block and saving it, opens fine... I'm just not sure how to do it
programmatically.

As you may have guessed I'm pretty new to VB.Net so please be
gental. ;)

Thanks for any suggestions!
 
Hi all.
We have some files that are basically TIF images with a text header.
The header portion is blocked by {startdb} and {enddb}.. it is the
same format for all the files.

What I need to do is read the file in, delete that block (including
the startdb and enddb) and write out the result as a TIF.
I can manually do this by loading them in a HEX editor, deleting the
block and saving it, opens fine... I'm just not sure how to do it
programmatically.

As you may have guessed I'm pretty new to VB.Net so please be
gental. ;)

Thanks for any suggestions!

You'll need to use the BinaryReader and BinaryWriter classes. You
can't simply delete a block of binary content, you will need to read
the file into a BinaryReader and write out the part you want to keep
to a new file with a BinaryWriter.
 
You'll need to use the BinaryReader and BinaryWriter classes. You
can't simply delete a block of binary content, you will need to read
the file into a BinaryReader and write out the part you want to keep
to a new file with a BinaryWriter.

Thanks a lot!
Any suggestions on where I can start looking for info on how to write
out everything after the {enddb}?

Thanks for any info!
 
Thanks a lot!
Any suggestions on where I can start looking for info on how to write
out everything after the {enddb}?

Thanks for any info!

I figured out how to read and write binary files from the MSDN help.
Plenty of sample code.

One thing you will need to know is exactly what hex character or
characters is used to represent the {enddb}. Read up to that point,
and then everything you read after than, write out to the new file.
 
Back
Top