Set password for files???

Aug 14, 2010 at 5:35 AM

Hello friends,

I am using sevenzipsharp library and i want to set password for files.

below is my code snippet

public static SevenZipCompressor cmp = new SevenZipCompressor();

cmp.CustomParameters.Add("pass", "password");

cmp.CompressFiles(outPath, filePath);

and i am getting error that,

"Input string was not in a correct format."

Please suggest any solution.

Thanks and Regards,


Jan 6, 2011 at 1:36 PM

I am also finding this problem - anyone know what im doing wrong?

var compressor = new SevenZipCompressor();

//Set low to keep things quick
compressor.CompressionMethod = CompressionMethod.Deflate;
compressor.CompressionLevel = CompressionLevel.None;
compressor.CustomParameters.Add("pass", "test");
compressor.ZipEncryptionMethod = ZipEncryptionMethod.Aes256;
compressor.CompressStream(m_basestream, m_OutputStream);


Many thanks

Jan 6, 2011 at 3:00 PM


The parameter "pass" is not the password - you simply pass it as a parameter into the compress function of your choice

 compressor.CompressStream(m_basestream, m_OutputStream, passwordString);


The example in the tests are not actually trying to put a password on it.....

Feb 12, 2011 at 10:20 AM
Edited Feb 12, 2011 at 11:17 AM


 i want to use the sevenzipsharp in

i have referenced the sevenzipsharp.dll in my project

and also set the library path for 7zip.dll

Below is the code which i am using


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SevenZip.SevenZipCompressor.SetLibraryPath("L:\vbtesting\testing zipping\7z.dll")
        Dim zipfile As New SevenZip.SevenZipCompressor()
        zipfile.ArchiveFormat = SevenZip.OutArchiveFormat.Zip
        zipfile.CompressionMethod = SevenZip.CompressionMethod.Lzma
        zipfile.CompressionLevel = SevenZip.CompressionLevel.Normal
        zipfile.ZipEncryptionMethod = SevenZip.ZipEncryptionMethod.Aes256
        zipfile.EncryptHeaders = True
        zipfile.CompressFilesEncrypted("L:\vbtesting\testing zipping\", "abcd", "L:\vbtesting\testing zipping\abc.xls")
    End Sub
End Class

This code is getting compiled and a zip file is getting created. But when i try to open this zip via 7-zip software then i get error unsupported compression method for abc.xls

i tried different compression method such as copy, default, lzma2, deflate.

All seem to give same error. the problem is i want to programmatically zip but the clients will always open via already available 7-Zip software.

please help,