Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET How to change a password for a zip file

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20366 |

    Hi,

     

    I want to change the password for a zip file.

    Currently I am unzipping the file with an Old password and zipping back with a New password. The zip files are huge, So is there any other way that I can simply change the password with out unzipping and zipping files.

    Imported from legacy forums. Posted by CrazyGeek (had 4281 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    You just need to overwrite the wanted file with a new Encryption Password set on the ZipArchive:

    e.g.,
    AbstractFile zipFile = new DiskFile( @”D:\Dump\113449\Archive.zip” );
    ZipArchive archive = new ZipArchive( zipFile );

    //Adding a file to an archive
    AbstractFile file = new DiskFile( @”D:\Dump\Test.txt” );
    archive.DefaultEncryptionPassword = “Soleil”;
    file.CopyTo( archive, true );

    //Overwriting a file to change the password
    archive.DefaultEncryptionPassword = “Sun”;
    file.CopyTo( archive, true );

    Imported from legacy forums. Posted by Alain [Xceed] (had 373 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi,

    The code what you mentioned will work only If I have the uncompressed source file. I don’t have the uncompressed source file. I have only the zip file. If i want to get the uncompressed source file I need to unzip the file and then zip it with new password. I am already using that approach.

    Thanks,

     

     

     

     

    Imported from legacy forums. Posted by CrazyGeek (had 1370 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.