Delete files in an ISO image with C#

585 Views Asked by At

I'm developping an application with C# that create an ISO image from a CD/DVD, then it lets the user to delete files contained in the Iso file, but so far I didn't find a way to do it. Please if you have any idea. Thanks in advance

1

There are 1 best solutions below

0
On

You should just change the order in which your program operates. Read in the file hierarchy first, then allow the user to select which files to delete, and then write the remaining out as an ISO file. You should be able to keep the files and directories in a tree data structure. Deleting a folder or file would just delete a corresponding node or leaf.

As to the question of directly deleting a file or directory in an ISO image, the same rules above apply, as the ISO9660 (ECMA-119) format is essentially a serialized tree structure. Simply zero out the corresponding records for the subtrees and leafs you want to delete. Do note however, that such an approach will leave garbage space in the image. And that to actually get the image to be smaller in size, you would need to do a compression operation on the image (re-serialize the hierarchy out to a new file).