Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Adding files to pre-existing zip files with Real time product

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20401 |

    How do I go about adding files to pre-existing zip files using the streaming product? Keep in mind, this archive was created and closed before I attempt to add the new file.  So far, I only replace the file in the zip instead of adding a new one.

    ZipItemLocalHeader itemHeader = new ZipItemLocalHeader(textBox_FileName.Text, CompressionMethod.Deflated64, CompressionLevel.Highest, EncryptionMethod.WinZipAes, “”);

    if (File.Exists(textBox_archive.Text))

    {

    FileStream fstream = new FileStream(textBox_archive.Text,FileMode.Open,FileAccess.ReadWrite);

    fstream.Seek(0, SeekOrigin.End);

    ZipWriter zip = new ZipWriter(fstream);

    FileStream x = new FileStream(textBox_FileName.Text, FileMode.Open, FileAccess.Read);

    ZipArchive z = new ZipArchive(textBox_archive.Text);

    z.BeginUpdate();

    zip.WriteItemLocalHeader(itemHeader);

    int readBytesCount = 0;

    byte[] readBytes = new byte[8192];

    while ((readBytesCount = x.Read(readBytes, 0, readBytes.Length)) != 0)

    {

    zip.WriteItemData(readBytes, 0, readBytesCount);

    }

    x.Close();

    zip.CloseZipFile();

    }

    else

    {

    MemoryStream compressedStream = new MemoryStream();

    FileStream fileStream = new FileStream(textBox_FileName.Text, FileMode.Open, FileAccess.Read);

    ZipWriter zipWriter = new ZipWriter(compressedStream);

    zipWriter.WriteItemLocalHeader(itemHeader);

    int readBytesCount = 0;

    byte[] readBytes = new byte[8192];

    while ((readBytesCount = fileStream.Read(readBytes, 0, readBytes.Length)) != 0)

    {

    zipWriter.WriteItemData(readBytes, 0, readBytesCount);

    }

    zipWriter.CloseZipFile();

    FileStream zip = new FileStream(textBox_archive.Text, FileMode.OpenOrCreate, FileAccess.Write);

    compressedStream.Seek(0,

    SeekOrigin.Begin);

    zip.Write(compressedStream.ToArray(), 0, (

    int)compressedStream.Length);

    zip.Close();

    fileStream.Close();

    }

    Imported from legacy forums. Posted by Martin (had 1154 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Martin,

    The Real-Time Zip component was designed to create
    new zip files only. Appending is not supported and there is no plan at
    the moment to support it in a future version of the product. 

    Imported from legacy forums. Posted by Marc [Xceed] (had 1025 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.