473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Removing bytes from a file

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.
Nov 15 '05 #1
1 1734
Tristan <tr************@yahoo.co.uk> wrote:

<snip>
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: bart_nessux | last post by:
Hello, I have some Macbinary files on a PC. I want to recursively read these files and remove the first 128 bytes of the files if they contain the macbinary header info. I know how to read...
1
by: ChrisC | last post by:
Im having trouble removing line breaks from my c# string. Actually, im having trouble getting .Trim() to work properly, as it seems to count a string that has nowt but a break of some sort as not...
10
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
4
by: sri2097 | last post by:
Hi all, I'm storing number of dictionary values into a file using the 'cPickle' module and then am retrieving it. The following is the code for it - # Code for storing the values in the file...
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
16
by: junky_fellow | last post by:
Is there any efficcient way of removing the newline character from the buffer read by fgets() ? Is there any library function that is similar to fgets() but also tells how many bytes it read...
9
by: Rajarshi | last post by:
Hi, I have some code that takes a string and obtains a compressed version using zlib.compress Does anybody know how I can remove the header portion of the compressed bytes, such that I only have...
2
by: polohero | last post by:
I am using an FtpClient.cs that someone else created and when I'm uploading (it uses a Socket) a file a carriage return is getting deleted when the file appears on the ftp location. Normally this...
3
by: akadeco | last post by:
Hi Could anyone give me some pointers on how to remove subdomains from a string? For example: If the string was bytes.com, it would stay bytes.com If it was subdomain.bytes.com, it would...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.