【发布时间】:2020-05-22 04:35:27
【问题描述】:
我正在尝试使用 Xamarin.Forms 中的 SharpZipLib 从 HttpClient 解压缩流。此代码在 iOS 上完美运行,但在 Android 上 CanDecompressEntry() 始终返回 false。我错过了什么?也许Android需要一些权限?
var zipStream = await httpClient.GetStreamAsync(url);
using (ZipInputStream s = new ZipInputStream(zipStream))
{
ZipEntry theEntry;
//const int size = 2048;
byte[] data = new byte[2048];
Debug.WriteLine(s.CanDecompressEntry);
while ((theEntry = s.GetNextEntry()) != null)
{
if (theEntry.IsFile)
{
string str = "";
while (true)
{
int size = s.Read(data, 0, data.Length);
if (size > 0)
{
str += new UTF8Encoding().GetString(data, 0, size);
}
else
{
files.Add(theEntry.Name.Substring(0,theEntry.Name.Length-5), str);
break;
}
}
}
}
}
return files;
【问题讨论】:
标签: xamarin.forms xamarin.android xamarin.ios httpclient sharpziplib