desautelsj
desautelsj

Reputation: 3715

Creating a ZipFile from byte[] no longer available?

There used to be a convenient static method in previous version of Ionic.Zip.Reduced that allowed to create a ZIP file from a byte array:

public static ZipFile Read(byte[] buffer)

My code looked something like this:

byte[] data = GetMyData();
ZipFile zip = ZipFile.Read(data);

However, this method is no longer available in the most recent version. Why is that?

I came up with the following code which I believe is the equivalent:

byte[] data = GetMyData();
return ZipFile.Read(new MemoryStream(data));

Is the new code equivalent?

Upvotes: 2

Views: 1143

Answers (1)

Babak Naffas
Babak Naffas

Reputation: 12561

'Why' is more a question for the DotNetZip team. I have a few ideas, though.

  1. Best practice for naming methods: If you consider the name of the method, it doesn't make sense to Read an array.
  2. Memory utilization: They are probably assuming that their users were already using a MemoryStream to generate the byte[] value and this new method prevents the double entry in memory.

Upvotes: 2

Related Questions