Just did some research and think the problem is the sequence for the files in the cab. As files in InstallShield are not sorted alphabetically and the sequence number has no gaps (at first glance) following code with two Lists containing the files in the correct orders seems to work for me. Hope it helps maybe somebody else (As usual with no warranty):
// define needed variables string inCab = "C:\\Data1.cab"; string outCab = "C:\\out\\Data1.cab"; // Set a temp folder for extracting the cabs string tempDirectoryTempFolder = "c:\\tempExtracted"; // set input cab and unpack it to extractedFilesDirectory CabInfo cabIn = new CabInfo(inCab); cabIn.Unpack(tempDirectoryTempFolder); // build sourceFileList and filelist with files from cabIn List<string> sourceFileList = new List<string>(); List<string> fileList = new List<string>(); foreach (CabFileInfo fileInfo in cabIn.GetFiles()) { sourceFileList.Add(tempDirectoryTempFolder + "\\" + fileInfo.Name.Trim()); fileList.Add(fileInfo.Name.Trim()); } // Create outCab with defined compression level and the two lists CabInfo cabOut = new CabInfo(outCab); cabOut.PackFiles(tempDirectoryTempFolder, sourceFileList, fileList, Microsoft.Deployment.Compression.CompressionLevel.None, null); 2011/1/13 Tobias S <tobias.s1...@gmail.com>: > Hello, > > Is it possible to change programatically the compression level of a > cab file with keeping its internal referencial structure intact ? > Initially I tried to "unCab" and "cab" an InstallShield generated cab > using > > ... > using Microsoft.Deployment.Compression.Cab; > ... > > CabInfo cabInfo = new CabInfo("C:\\Data1.cab"); > cabInfo.Unpack("D:\\ExtractedFiles"); > > CabInfo cabNew = new CabInfo("C:\\Data2.cab"); > cabNew.Pack("D:\\ExtractedFiles", true, > Microsoft.Deployment.Compression.CompressionLevel.None, null); > ... > > But as expected this produced a cab which did not work anymore. I > assume the internal referencing structure went wrong. Checking > http://www.codeproject.com/KB/files/CABCompressExtract.aspx I also > re-checked whether the InstallShield Cabs are MicroSoft Cab File > compatible (first four bytes are "MSCF"). Unfurtunately I'm not so > deep in DTF yet to figure out what is missing and how to handle that. > > Maybe for the goal of the whole actions: Re-Compressing existing CAB > files to have no compression (CompressionLevel=none). This is needed > on the one hand side for generating compression less CABs from > InstallShield (IS seems to have no configuration ability for that) and > re-compress WiX cabs to CompressionLevel=none. Then we can pack these > installations e.g. with LZMA (7-zip) to ship the small packages over > Internet or get a better compression rate when such a package includes > an x86 and x64 cab where many files are identical. > > Best regards > Tobias > ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users