Good day. I understand the source of one program that unpacks rar-files (NUnrar - https://nunrar.codeplex.com/SourceControl/latest ). So, how to use it:

RarArchive archive = RarArchive.Open(path);

In this line, an object is created in which the primary information about the rar file is collected (how many files are inside it, whether it is password protected, etc.) The problem is that the Open() method needs to pass the path to the file to the input, which for me not very comfortable. There are several overloads of this method in the library. Here they are:

  `public static RarArchive Open(FileInfo fileInfo); public static RarArchive Open(IEnumerable<Stream> streams); public static RarArchive Open(Stream stream); public static RarArchive Open(string filePath); public static RarArchive Open(FileInfo fileInfo, RarOptions options); public static RarArchive Open(IEnumerable<Stream> streams, RarOptions options); public static RarArchive Open(Stream stream, RarOptions options); public static RarArchive Open(string filePath, RarOptions options);` 

It would be much more convenient for me to transfer an array of file bytes to the input of this function. How do you literally do this?

    1 answer 1

    One of the overloads takes the Stream , and you can create it from an array of bytes using the MemoryStream :

     Stream s = new MemoryStream(byteArray); RarArchive archive = RarArchive.Open(s); 
    • that's what inattention means. Thank! - Setplus