Esempio n. 1
0
            public void UnpackArchive(string filename, string destinationFolder, byte[] password)
            {
                RAROpenArchiveData archiveData = new RAROpenArchiveData();
                RARHeaderData      headerData  = new RARHeaderData();

                archiveData.ArcName  = filename + '\0';
                archiveData.OpenMode = RAR_OM_EXTRACT;
                archiveData.CmtBuf   = null;

                IntPtr rarHandle = RAROpenArchive(ref archiveData);

                try
                {
                    if (archiveData.OpenResult != 0)
                    {
                        throw new Exception("Could not open the RAR archive " + filename);
                    }
                    RARSetPassword(rarHandle, password);
                    if (RARReadHeader(rarHandle, ref headerData) != 0)
                    {
                        throw new Exception("Could not read any file in the RAR archive " + filename);
                    }
                    if (RARProcessFile(rarHandle, 2, destinationFolder, null) != 0)
                    {
                        throw new Exception("Could not unpack the file in the RAR archive " + filename);
                    }
                }
                finally
                {
                    RARCloseArchive(rarHandle);
                }
            }
Esempio n. 2
0
 private static extern IntPtr RAROpenArchive(ref RAROpenArchiveData archiveData);
Esempio n. 3
0
 private static extern IntPtr RAROpenArchive(ref RAROpenArchiveData archiveData);
Esempio n. 4
0
 public static extern IntPtr RAROpenArchive(ref RAROpenArchiveData archiveData);