每当我尝试获取文件时,输入流(s.Length)的长度总是零,我做错了什么?ZipEntry有效并且具有适当的文件大小,等等。
下面是我使用的代码:
public static byte[] GetFileFromZip(string zipPath, string fileName)
{
byte[] ret = null;
ZipFile zf = new ZipFile(zipPath);
ZipEntry ze = zf.GetEntry(fileName);
if (ze != null)
{
Stream s = zf.GetInputStream(ze);
ret = new byte[s.Length];
s.Read(ret, 0, ret.Length);
}
return ret;
}发布于 2010-06-04 10:17:56
输入流将没有长度。请改用ZipEntry.Size。
public static byte[] GetFileFromZip(string zipPath, string fileName)
{
byte[] ret = null;
ZipFile zf = new ZipFile(zipPath);
ZipEntry ze = zf.GetEntry(fileName);
if (ze != null)
{
Stream s = zf.GetInputStream(ze);
ret = new byte[ze.Size];
s.Read(ret, 0, ret.Length);
}
return ret;
}https://stackoverflow.com/questions/2971079
复制相似问题