Removing bytes from a file

  • Thread starter Thread starter Tristan
  • Start date Start date
T

Tristan

Hi,

My application writes out files to disk containing representations
of shapes, with no problems.

I also have an index file written out which stores the shape number
and its byte offset in the main file so a specific shape can be
retrieved easily.

The problem I have is how to delete a shape from the main file.
I can seek to the position of the shape to be deleted but have
no idea as to what to do then.

I need to delete the shape and shift the rest of the data beneath
it upwards in the file.

Are there any nice classes/methods in .NET to do this? I am trying
to avoid rewritting out the entire file again if possible.

Many thanks

Tristan.
 
Are there any nice classes/methods in .NET to do this? I am trying
to avoid rewritting out the entire file again if possible.

You may be able to rewrite only from where the old shape was, but you
won't be able to avoid rewriting that.

What you *could* do is just not have the shape in the index any more,
so you have a part of the file which is effectively unused. Every so
often you could the rewrite the fragmented file, only keeping the
useful bits.
 
Back
Top