đang cố gắng thêm tệp vào lưu trữ hiện có bằng cách sử dụng mã sau. Khi chạy không có lỗi hoặc ngoại lệ được hiển thị nhưng không có tệp nào được thêm vào lưu trữ. Bất kỳ ý tưởng tại sao?C# sharpziplib thêm tệp vào kho lưu trữ hiện tại
using (FileStream fileStream = File.Open(archivePath, FileMode.Open, FileAccess.ReadWrite))
using (ZipOutputStream zipToWrite = new ZipOutputStream(fileStream))
{
zipToWrite.SetLevel(9);
using (FileStream newFileStream = File.OpenRead(sourceFiles[0]))
{
byte[] byteBuffer = new byte[newFileStream.Length - 1];
newFileStream.Read(byteBuffer, 0, byteBuffer.Length);
ZipEntry entry = new ZipEntry(sourceFiles[0]);
zipToWrite.PutNextEntry(entry);
zipToWrite.Write(byteBuffer, 0, byteBuffer.Length);
zipToWrite.CloseEntry();
zipToWrite.Close();
zipToWrite.Finish();
}
}
Tôi đã cập nhật câu trả lời của mình. –