If you want to change the contents of a file (if it's a file), you need to rewrite the rest. There is no way of adding or deleting something in the middle of the file as it is a stream. So the basic algorithm is to read all before the text you want to discard, write it to a file (or just seek after the block) and then read the rest of the file (after the text you want to discard) and write it right after the first block.





Reply With Quote
Bookmarks