在c#项目中使用unrar.dll来检索文件列表和相关的CRC代码

本文关键字:列表 文件 代码 CRC 检索 项目 dll unrar | 更新日期: 2023-09-27 18:14:42

从这个链接https://social.msdn.microsoft.com/Forums/vstudio/en-US/022a0806-bb30-4cea-b446-bc20c7dd4838/extracting-files-using-rarprocessfile-of-unrardll-doesnt-work?forum=csharpgeneral

我已经复制了在第二个帖子的以下链接中找到的所有代码…该程序的工作,但它提取所有文件,而我想做一个txt文件在同一目录下,那里有rar文件的文件名和crc代码的列表;

所以我编辑了行代码
CharToOem("C:''Documents and Settings''Administrator''Desktop''New Folder", sbDir);

CharToOem(ExtractDir, sbDir);

使txt文件在同一目录下,但我必须编辑以下行代码

while (RARReadHeader(lHandle, ref uHeader) == 0)
  {
    int result = RARProcessFile(lHandle, 2, sbDir.ToString(), null);
    if (0 != result)
      MessageBox.Show("Unable to open the Archieve!!!");
  }

创建一个txt文件,并写入所有文件的名称(带有"uHeader.FileName;")和crc(带有"uHeader.FileCRC;");我如何滚动rar存档中的所有文件?

在c#项目中使用unrar.dll来检索文件列表和相关的CRC代码

查看网页:http://www.rarlab.com/technote.htm,您必须找到每个标题的末尾才能获得下一个标题。这并不容易,因为头文件有可变长度的字符串(以''0'结束)。整数大小固定为4字节。因此,您必须编写一个例程来解析头文件以查找下一个头文件。

格式如下

General archive layout
    Self-extracting module (optional)
    RAR 5.0 signature
    Archive encryption header (optional)
    Main archive header
    Archive comment service header (optional)
    File header 1
    Service headers (NTFS ACL, streams, etc.) for preceding file (optional).
    ...
    File header N
    Service headers (NTFS ACL, streams, etc.) for preceding file (optional).
    Recovery record (optional).
    End of archive header.