deleting 20 bytes from a file
Posted on 2002-07-19
I want to delete the first 20 bytes from a file
(not replacing them with blanks. the file must be
smaller in 20 bytes).
Currently I’m doing it by opening the file and using INPUT to read it into a string.
Then I write the string (without the first 20 bytes) into a new file, using PUT (in binary mode).
I’ve tried to read different sizes of blocks (up to the whole file at once) and timed the operation.
My problem is the speed.
The fastest code I’ll get here will get the points with an A grade.
For a test file I use a 3.8MB mp3 file. The best result I got on this machine is 30 seconds which is very slow.
I consider it very slow because winzip compress the same file in 5 seconds on same machine. Since winzip does not make mp3 files smaller, and it writes a new file – it means that it use a totally different approach then mine. I am not talking about compression here. I’m only talking about the action of rewriting the file.
I’ll wait for answers until someone will come with a code that will be close to Winzip performance. Since it’s VB here – I don’t expect winzip’s 5 seconds, but I sure expect something below 10 seconds.
Please , don’t send verbal suggestions which you have not checked yourselves.
Such amount of points worth CODE that have been tested.