locked
Renaming entry in ZIP file RRS feed

  • Question

  • Is there a way to use Framework libraries (such as, ZipArchive or ZipFile) to renames file(s) in the archive without having to extract the content?

    Tuesday, April 26, 2016 6:58 AM

Answers

  • Hi hendrixf,

    >>Is there a way to use Framework libraries (such as, ZipArchive or ZipFile) to renames file(s) in the archive without having to extract the content?

    In .Net framework, we have ZipArchive  and ZipFile classes.  Unfortunately, ZipFile class provides static methods for creating, extracting, and opening zip archives.  ZipArchive Class represents a package of compressed files in the zip archive format. There is no rename function in both of them. You should write it by yourself.

    But there is a third-party library to help you implement this,  DotNetZip is a .NET library for zip files that allows renaming of entries. 

    using (ZipFile zip1 = new ZipFile())
      {
          zip1.AddFile("myFile.txt").FileName = "otherFile.txt"; 
          zip1.Save(archiveName);
      }

    For more details, please refer to Add an entry, overriding its name in the archive

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by hendrixf Thursday, April 28, 2016 10:03 PM
    Wednesday, April 27, 2016 2:36 AM