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); } }
private static extern int RARReadHeader(IntPtr hArcData, ref RARHeaderData headerData);
public static extern RarError RARReadHeader(IntPtr hArcData, ref RARHeaderData headerData);
public static extern int RARReadHeader(IntPtr hArcData, ref RARHeaderData HeaderData);