0
설명서를 읽은 후이 작업을 수행하는 데 매우 어려움을 겪고 있습니다. Using ZipFile
메모리에 zip 파일을 생성 한 다음 업데이트 할 수 있습니다. 각 업데이트를 호출 할 때 zip은 0 항목이 있다고보고합니다.zip 파일 만들기 및 업데이트
내가 뭘 잘못하고 있니?
public void AddFile(MemoryStream zipStream, Stream file, string fileName)
{
//First call to this zipStream is just an empty stream
var zip = ZipFile.Create(zipStream);
zip.BeginUpdate();
zip.Add(new ZipDataSource(file), fileName);
zip.CommitUpdate();
zip.IsStreamOwner = false;
zip.Close();
zipStream.Position = 0;
}
public Stream GetFile(Stream zipStream, string pathAndName)
{
var zip = ZipFile.Create(zipStream);
zip.IsStreamOwner = false;
foreach (ZipEntry hi in zip) //count is 0
{
}
var entry = zip.GetEntry(pathAndName);
return entry == null ? null : zip.GetInputStream(entry);
}
사용자 정의 데이터 소스
public class ZipDataSource : IStaticDataSource
{
private Stream _stream;
public ZipDataSource(Stream stream)
{
_stream = stream;
}
public Stream GetSource()
{
_stream.Position = 0;
return _stream;
}