Quantcast
Channel: sharpcompress Discussions Rss Feed
Viewing all articles
Browse latest Browse all 239

New Post: reading certain entry

$
0
0

Is it possible to get certain entry without,unpacking it on disc?
This is what I have done so far.The problem here is the while loop...Each execution of reader.MoveToNextEntry(); takes ~50ms so if I have a rar with 1k images,it almost takes 1min to get to last image...

public static System.Drawing.Image ReadPageFromRar(string pathToFile, int page)
        {
            using (Stream stream = File.OpenRead(pathToFile))
            {
                var reader = ReaderFactory.Open(stream, SharpCompress.Common.Options.KeepStreamsOpen);
                int currentPage = 0;

                while (currentPage != page)
                {
                    reader.MoveToNextEntry();
                    currentPage++;
                }

                using (var entryStream = reader.OpenEntryStream())
                {
                    return Bitmap.FromStream(entryStream);
                }
            }
        }
using (Stream stream = File.OpenRead(@"C:\a.cbr"))
        {
            var arch = ArchiveFactory.Open(stream, SharpCompress.Common.Options.KeepStreamsOpen);

            foreach (var entry in arch.Entries)
            {
                using (var entryStream = entry.OpenEntryStream())
                {
                    Bitmap.FromStream(entryStream);
                }
            }
        }

This code throws exception The method or operation is not implemented. in SharpCompress.Compressor.Rar.CanSeek


Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>