-2147024882: could not pack files

Apr 20, 2009 at 4:41 AM
Edited Apr 20, 2009 at 5:00 AM

With a simple test application as below, error is thrown while compressing certain files. Some .gifs, some .asp files etc. cannot find anything consistent to narrow it to, which is why i am posting this. i am writing in vb.net but converted the basics of what i am doing to c# to make sure the problem wasnt my coding in vb.

the error is the follwing:

"Could not pack files! Message: The compression has failed for an unknown reason with code -2147024882."

the code is in the compressfiles method of sevenzipcompressor.cs. line #419 specifically.

i have sample data i am working with. i could send a small zipped up file to you to work with on testing. let me know.

example code:

static void ProcessFiles(string path)
string[] files;
string[] directories;

files = Directory.GetFiles(path);
foreach (string file in files)
// Process each file

directories = Directory.GetDirectories(path);
foreach (string directory in directories)
// Process each directory recursively

static void compress(string sFile)
SevenZipCompressor.SetLibraryPath(@"c:\Program Files\7-Zip\7z.dll");
SevenZipCompressor tmp = new SevenZipCompressor();
tmp.FileCompressionStarted += new EventHandler<FileInfoEventArgs>((s, e) =>
Console.WriteLine(String.Format("[{0}%] {1}",
e.PercentDone, e.FileInfo.Name));
tmp.CompressFiles(new string[] { sFile }, sFile + ".7z", OutArchiveFormat.Zip);

static void Main(string[] args)
Console.WriteLine("SevenZipSharp test application.");

Apr 20, 2009 at 9:48 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 22, 2009 at 1:06 PM
The issue seems to have been fixed.
Apr 22, 2009 at 1:19 PM
Edited Apr 22, 2009 at 1:20 PM
in what version?  how do i get the code?


i found the code.  am downloading and testing now.  will post results.
Apr 22, 2009 at 1:55 PM
Edited Apr 22, 2009 at 2:18 PM
the following line used to work in the previous version of code:

tmp.CompressDirectory(sDir, sArchiveName, OutArchiveFormat.SevenZip)

now a compile error is raised regarding overload resolution failure.  it seems i cant specify the format type anymore.


looks like the definition was changed.  i modified my code and it appears to be working.

Apr 22, 2009 at 4:14 PM
Now if you want to specify the archive format (7z is the default), you write
(SevenZipCompressor).ArchiveFormat = OutArchiveFormat.(...);
This change was made for more convenient control under compression parameters.
Apr 22, 2009 at 4:30 PM
i just realized that.  it is awesome.  makes the call to compress much cleaner.

thanx for all the work you are doing.  i really appreciate it.