This is a discussion on How to Create a Cab file in C#? within the C# Programming forums, part of the Software Development category; Hi, I want to create a cab file in C# and Extract it and Install it in a particular path? ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, I want to create a cab file in C# and Extract it and Install it in a particular path? Can anyone tell me how the cab file is created?
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| Sponsored Links |
| |||
| Hi, A cabinet (.cab) file is a library of compressed files stored as a single file. Cabinet files are used to organize installation files that are copied to the user's system. A large compressed file can be spread over several .cab files. Each file compressed in a .cab file is stored completely within a single folder. Create a C# project and the copy and paste the following code then extract the zip file attched with this post and add the dll as reference. String s_EncryptionKey = ""; String s_CompressFile = ""; String s_DecryptDir = ""; CabLib.Compress i_Compress = new CabLib.Compress(); CabLib.Extract i_Extract = new CabLib.Extract(); [DllImport("kernel32.dll", EntryPoint = "GetWindowsDirectoryA", CharSet = CharSet.Ansi)] private static extern int GetWindowsDirectory(StringBuilder s_Text, int MaxCount); [DllImport("kernel32.dll", EntryPoint = "GetCurrentDirectoryA", CharSet = CharSet.Ansi)] private static extern int GetCurrentDirectory(int MaxCount, StringBuilder s_Text); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int s32_SplitSize = 0x7FFFFFFF; StringBuilder s_WinDir = new StringBuilder(500); GetWindowsDirectory(s_WinDir, 500); String s_Explorer = s_WinDir + "\\Explorer.exe"; String s_Notepad = s_WinDir + "\\Notepad.exe"; StringBuilder s_WorkDir = new StringBuilder(500); GetCurrentDirectory(500, s_WorkDir); String s_CompressDir = s_WorkDir + "\\_Compressed"; s_DecryptDir = s_WorkDir + "\\_Decrypted"; String s_ResourceDir = s_WorkDir + "\\_ExtractResource"; s_CompressFile = s_CompressDir + "\\Packed_%d.cab"; i_Compress.SetEncryptionKey(s_EncryptionKey); i_Extract.SetDecryptionKey(s_EncryptionKey); ArrayList i_Files = new ArrayList(); i_Files.Add(new string[] { s_Explorer, @"FileManager\Explorer.exe" }); i_Files.Add(new string[] { s_Notepad, @"TextManager\Notepad.exe" }); i_Compress.CompressFileList(i_Files, s_CompressFile, s32_SplitSize); MessageBox.Show("Cab File Created"); } This is the sample for creating a cab file. Thanks.. S.Balasubramanian.. |
| |||
| Hi, I checked your code. It is working fine. It only create a cab file. I want to extract a cab file in a particular path and install it.
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| |||
| Hi, Use this code to extract a cab file. Copy the code and add the same dll as reference. s_CompressFile = s_CompressFile.Replace("%d", "1"); i_Extract.ExtractFile(s_CompressFile, s_DecryptDir); Thanks.. S.Balasubramanian.. |
| |||
| Hi, I executed your code. It works on creating a cab file and extract it. Please tell me how many types of cab files available? and give me brief explanation..
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| |||
| Hi, There are two completely different types of CAB files: 1) The ones which this project supports are the "Microsoft CAB" files (also called "MS-CAB"). The Microsoft pack format is also known as MSZIP. 2)InstallShield created the "InstallShield CAB" files. But these are absolutely incompatible with the MS-CAB files although they use the same file extension If you open a MS-CAB file with a hex editor, you will notice that the first four bytes are "MSCF" (MicroSoft Cab File), while the first three bytes of an InstallShield-CAB file are "ISc". (InstallShield Cab). You cannot open or create InstallShield CAB files with this project. There exist only very few tools which are capable of managing InstallShield CAB files; Thanks.. S.Balasubramanian.. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code-behind to create node dynamically using XML File or any Stored Procedure | poornima | ASP and ASP.NET Programming | 3 | 02-14-2008 09:46 PM |
| How to create a Setup file in VS 2005 to start a installer from a installer file? | $enthil | C# Programming | 2 | 11-16-2007 03:10 AM |
| How to read inbox messages in windows mobile and create it as a text file using C#? | mobilegeek | Windows Mobile | 4 | 08-17-2007 07:42 AM |
| How to create a ZIP File in Java? | bluesky | Java Programming | 1 | 07-25-2007 06:03 AM |
| Is it possible to create an .ini file for CEAppMgr that will disable.. | theone | Mobile Software Development | 1 | 07-19-2007 01:00 AM |