Exception: "Value does not fall within the expected range" using SevenZipCompressor

Jul 20, 2011 at 4:42 PM

Hi,

I'm using the following code to try and create a bzip2 archive, but am getting an exception thrown, but I can't see anything wrong with the way i'm doing things:

 

if (_CompressOutput)
{
    try
    {
         SevenZip.SevenZipCompressor.SetLibraryPath("C:\\Program Files (x86)\\7-Zip-32bit\\7z.dll"); //TODO: Use better location for dll..
         string _CompressedSaveFile = _SaveFile + ".bz2";
         SevenZip.SevenZipCompressor Comp = new SevenZip.SevenZipCompressor(System.IO.Path.GetTempPath());
         Comp.ArchiveFormat = SevenZip.OutArchiveFormat.BZip2;
         Comp.CompressionMethod = SevenZip.CompressionMethod.BZip2;
         Comp.CompressionMode = SevenZip.CompressionMode.Create;
         Comp.CompressFiles(_CompressedSaveFile, _SaveFile);
         System.IO.File.Delete(_SaveFile);
     }
     catch (SevenZip.SevenZipException e)
    {
         System.Windows.Forms.MessageBox.Show(string.Format("Error whilst compressing disk image {0}:\n{1}", _SaveFile, e.Message), "Error!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
         Successful = false;
    }
}

Sorry if I've done something obviously wrong or not read something I should have done, just point me in the right direction and I can do the reading/learning myself!

 

Thanks

Jul 20, 2011 at 4:54 PM

Here's a stack trace for the exception if it helps anyone..

 

StackTrace:

 at SevenZip.ISetProperties.SetProperties(IntPtr names, IntPtr values, Int32 numProperties)

at SevenZip.SevenZipCompressor.SetCompressionProperties()

at SevenZip.SevenZipCompressor.GetArchiveUpdateCallback(FileInfo[] files, Int32 rootLength, String password)

at SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, Int32 commonRootLength, String password, String[] fileFullNames)

at SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, Int32 commonRootLength, String password, String[] fileFullNames)

at SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, String password, String[] fileFullNames)

at SevenZip.SevenZipCompressor.CompressFiles(String archiveName, String[] fileFullNames)

at XXXX.DriveImager.AsyncMakeImage() in c:\\users\\xxxxxx\\documents\\visual studio 2010\\Projects\\XXXX\\XXXX\\DriveImager.cs:line 86

Aug 17, 2011 at 7:58 AM

Hi.

Recently had the same experience.

http://sevenzipsharp.codeplex.com/workitem/9077