Results 1 to 4 of 4

Thread: Zip archive delete question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    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
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    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
  •  



Click Here to Expand Forum to Full Width