// 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();
}
}
我编写此代码以使用 SharpCompress 从 Rar 文件中提取 IEntries(我不想向用户询问广泛的FileSystemAccess 功能),因此我正在使用流。有没有办法让它更快?我的代码很慢。