Results 1 to 4 of 4

Thread: Zip archive delete question

  1. #1
    Frenzied Member
    Join Date
    Sep 08
    Posts
    1,028

    Zip archive delete question

    I have had a look at the MSDN site for the ZipArchive with no luck.

    This is my question: Is it possible to delete a file from a ZipArchive singly rather than have to extract the whole archive, and then create a new archive without the file that I do not want in there?

    Basically, what is the easiest way to remove a file from a ZipArchive?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,785

    Re: Zip archive delete question

    I've never used that functionality myself but, from what I can see, I'd say that the answer is no. My immediate thought was that you would Remove an entry from the Entries collection but it is read-only. I'd say that you'll have to create a new ZipArchive, copy all the entries across and then replace the original file with the new one. That's presumably what would have to be done behind the scenes anyway.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,785

    Re: Zip archive delete question

    Actually, I tell a lie. You get a ZipArchiveEntry from the ZipArchive and then call its Delete method. I appreciate that you had a go at MSDN for yourself but that took me just a few minutes to find when I've never used these types before simply by reading all the relevant documentation. Don't just stick to one type. Follow the links. I went to ZipArchive, then ZipArchive.GetEntry, then ZipArchiveEntry just by clicking the links and reading, and there was the answer.

  4. #4
    Frenzied Member
    Join Date
    Sep 08
    Posts
    1,028

    Re: Zip archive delete question

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •