LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete a portion from the start of a binary file

Solved!
Go to solution

OK,

Thank you all for replaying.

You raised some pretty good ideas.

All of them require some changes in my code and so I need some time to discuss the best way to go with my teammates...

Hope to update soon...

 

Thank you for all the help!

 

BR,

Mentos

0 Kudos
Message 11 of 13
(644 Views)
Solution
Accepted by topic author Mentos

I like "outside-the-box" thinking (a Kudo to Alexander Sobolev).  You can combine his clever idea (start at the end) with mine (make a small copy then "chop off" what you copied).  Here's a melding of our two ideas:

  • Start with one long file and "not quite enough free space".
  • Position yourself at a convenient place near the end of the file (say, around 15 GB in a 20 GB file, someplace where it is logical to make a break in the file).  Remember this position!
  • Copy from this position to the end of the file into a new file (copying forward, of course).  Close the new (5 GB in this example) file.
  • Do a "Set File Size" on the original File using the saved Position.  You now have your original file "shortened" to 15 GB, with the last 5 GB in a separate file.
  • Repeat, lopping off two more 5 GB pieces until you are left with 4 files, each 5 GB in size.  Of course, you need to make sensible file names for each of them (including the original, as it is now "short"), but that's a detail.

Bob Schor

Message 12 of 13
(624 Views)

Hi again,

 

Sorry for the long time...

I managed to implement the "outside the box" thinking you suggested as follows:

1) Reading a chunk of data from the END of the original file

2) Do "file size" to shorten the original file.

3) Save the read chunk in a new, temporary file

4) Repeat steps 1-3 to read all the data from the original file into small, separate, chunks files. No the original file is empty and all the data is stored in separate temporary data files.

5) Do another loop to combine all the separate data files into one big final data file (reverse chunk order so first read chunk from step#1 is the last to be saved into the big final file).

 

I did some tests and it seems to be working very nicely!

Bob and Alexander, I think you both deserve a Kudo!

 

Thank you very much and thanks for everyone who responded on this post.

 

0 Kudos
Message 13 of 13
(597 Views)