Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Real Time Zip for simultaneous writing to file

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

    this is the scenario:
    I need to compress a file using real time zip.
    While the file is getting compressed, i want to start writing the contents to a file or upload the stream to an ftp.
    Can i achieve this using real time zip?
    This is what i am doing at present:-
    1. Compressing the file as provided in the samples.
    2. Inside zipWriter.ByteProgression i am using the compressed memory stream,to do write operation or the ftp upload. the ftp upload function accepts a stream to upload.
    so every time a block[8192] is compressed to the compressedStream, the zipWriter.ByteProgression is raised and this is where, writing to a file or upload will be done.

    but, everytime the event is raised i jus get the length of compressed memory stream as “42” which probably is the size of the header.
    What am i doing wrong?
    Any suggestions sample would be appreciated.
    thanks

    Imported from legacy forums. Posted by Harpreet (had 3351 views)

    Xceed Support
    Member
    Post count: 5658

    You can use an FtpFile and call OpenWrite on it to obtain a writable stream to this remote file. This stream can be passed to the ZipWriter constructor and everything you write into the ZipWriter will be directly uploaded to the specified FtpFile:

    string hostname = “ftpserver”;
    int port = 21;
    string user = “user”;
    string pass = “pass”;

    using( FtpConnection connection = new FtpConnection( hostname, port, user, pass ) )
    {
    AbstractFile ftpZipFile = new FtpFile( connection, “FtpZipArchive.zip” );

    using( Stream uploadStream = ftpZipFile.OpenWrite( true ) )
    {
    using( ZipWriter writer = new ZipWriter( uploadStream ) )
    {
    // Write bytes directly into the ZipWriter, those bytes
    // will be directly uploaded to the Ftp server
    }
    }
    }

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

    User (Old forums)
    Member
    Post count: 23064

    thanks for the reply.
    I will check it out.

    One more question:

    How can i achieve the following:
    I want to start writing the compressed stream to a file on my hard disk, as soon as the compression is started.
    I want to do this, so that i dont have to wait for the entire compression to finish and then start writing to a file.
    I want to gain that extra performance edge through your component.
    Can i do it?
    Any help or code sample would be appreciated.
    Thanks 🙂

    Imported from legacy forums. Posted by Harpreet (had 305 views)

    User (Old forums)
    Member
    Post count: 23064

    Sorted out the problem with your sample code.
    Thanks

    Imported from legacy forums. Posted by Harpreet (had 4429 views)

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