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

    I have a problem with the ZipWriter on and FTP Stream.  If I run the code below on an empty Zip File it works fine. But when i try and append to the file I get a central header error. If i try to view the archive using the stream it also stops at the original entry. If i run similar code using a local FileStream and append to it, it works fine.

     any help would be greatly appreciated.

    using

    (FtpConnection connection = new FtpConnection(hostname, port, user, pass))

    {

    AbstractFile ftpZipFile = new FtpFile(connection, “test.zip”);

     

    using (Stream uploadStream = ftpZipFile.OpenWrite(false))

    {

    using (ZipWriter writer = new ZipWriter(uploadStream))

    {

    DirectoryInfo di = new DirectoryInfo(@”C:\testdir”);

    FileInfo[] files = di.GetFiles(“*.*”, SearchOption.AllDirectories);

    foreach (FileInfo file in files)

    {

     

    ZipItemLocalHeader itemHeader = new ZipItemLocalHeader(@”\” + file.FullName,

    CompressionMethod.Deflated64,

    CompressionLevel.Highest,

    EncryptionMethod.WinZipAes,

    encryptionPassword);

    writer.WriteItemLocalHeader(itemHeader);

    using (FileStream stream = file.OpenRead())

    {

    byte[] buffer = new byte[1024];

    int bytesRead = 0;

    while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)

    {

    writer.WriteItemData(buffer, 0, bytesRead);

    }

    }

     

    }

     

    }

    }

    }

     

    I belive the issue is the writer is appending the new data as it would a log file which is cuasing the problem. Is there another way to keep adding files using the Real-Time component and FTP?

    Imported from legacy forums. Posted by sniper (had 1030 views)

    Xceed Support
    Member
    Post count: 5658

    Hi sniper,

       Real-Time Zip does not support addind files to an already existing zip file by now. To do it, you must use ZipArchive class.

    Imported from legacy forums. Posted by Chris [Xceed] (had 337 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for the reply. Thats to bad though the real-time zip works great. will this be a consideration for future releases or is it just not possible given the way it streams it?

    Imported from legacy forums. Posted by sniper (had 330 views)

    Xceed Support
    Member
    Post count: 5658

    By now, the reason why it is not implemented is the fact that we would have to read almost the whole zip file to find the zip central directory (containing informations on all compressed files in the zip) to be able to know what is already in the zip and then, append the new files.

    It is in the pipeline, but we don’t have a time frame for it. If you really need this feature, it could be done in custom development. Just contact sales@xceedsoft.com by mail or by phone for more informations.

    Imported from legacy forums. Posted by Chris [Xceed] (had 1623 views)

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