I have created a binary file usinf CFile. Now, i want to delete some of the contents of this file. How to do this?
Printable View
I have created a binary file usinf CFile. Now, i want to delete some of the contents of this file. How to do this?
Create a new file and copy everything you do not want to delete ... I would propose.
regards
HoM
You cannot just delete part of a file unless the part to delete is at the end of the file. In that case you can just schrink the filesize to delete that part.
Otherwise, you need to read everything to memory and only write what you want back to a file or copy the relevant parts to a temporary file first, then delete the original file and move the temporary file to the correct filename.
You can use CFile::SetLength to reduce the file size.