1
// Create buffer
byte[] buffer = new byte[entry.Size];
// Create a file to store the contents 
StorageFile file = await extractFolder.CreateFileAsync(Path.GetFileName(entry.Key), CreationCollisionOption.ReplaceExisting);
// Store the contents 
using (IRandomAccessStream randomStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
    using (Stream outstream = randomStream.AsStreamForWrite())
    {
        using (var ms = new MemoryStream())
        {
            reader.OpenEntryStream().CopyTo(ms);
            buffer = ms.ToArray();
        }
        outstream.Write(buffer, 0, buffer.Length);
        outstream.Flush();
    }
}

I write this code to extract IEntries from Rar file using SharpCompress (I don't want to ask the user for broadFileSystemAccess capability) so I am using streams. Is there a way to make it faster? My code is to slow.

Lukas Körfer
  • 13,515
  • 7
  • 46
  • 62
Christos K.
  • 99
  • 3
  • 14

0 Answers0