我有一些大型 zip 文件正在下载,然后在我的程序中解压缩。性能很重要,我开始考虑的一个方向是是否可以开始下载,然后在数据到达时开始解压缩,而不是等待下载完成然后开始解压缩。这可能吗?根据我对 DEFLATE 的理解,理论上应该是可行的吧?
我目前使用 DotNetZip 作为我的 zip 库,但它拒绝对不可搜索的流采取行动。
代码将是这样的:
// HTTP Get the application from the server
var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.Method = "GET";
Directory.CreateDirectory(localPath);
using (var response = (HttpWebResponse)request.GetResponse())
using (Stream input = response.GetResponseStream())
{
// Unzip being some function which will start unzipping and
// return when unzipping is done
return Unzip(input, localPath);
}