Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET synchronizing object – simple progressbar updates

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

    I have zips working great using delegates, callbacks and a background worker thread – but I am hoping for a simpler solution.

    I just finished an FTP transfer test, using after assigning the synchronizing object and using the IAsyncResult object. It resulted in very clean code, and much simpler progressbar updating than I have been able to accomplish with the zipping/folder copying. I only found the synchronizing object in the FTP component though. Anyone have simple ways to zip folders using a progressbar?

    For reference – the code I found really simple in FTP looked like: (from the Winforms Application and Threading Help files)

    Dim client As New AsyncFtpClient()
    client.SynchronizingObject = Form1;
    Dim result As IAsyncResult = http://ftp.BeginSendFile(sPath & sMsiName, Nothing, Nothing)
    While Not result.IsCompleted
    Application.DoEvents()
    End While
    client.EndConnect( result )

    Private Sub ftp_FileTransferStatus(ByVal sender As Object, ByVal e As Xceed.Ftp.FileTransferStatusEventArgs) Handles http://ftp.FileTransferStatus
    With prg1
    .Position = e.AllBytesPercent
    .ToolTip = “average ” & BytesTokbps(e.AllBytesPerSecond) & ” kbps”
    End With
    End Sub

    Imported from legacy forums. Posted by Mike (had 3343 views)

    User (Old forums)
    Member
    Post count: 23064

    You can initialize a ZipEvents object, subscribe to the different events available on this object, and pass the object to the CopyTo/CopyFilesTo methods. This will trigger the events as files are processed, and you will be able to update your progress bar, exactly as you do in the FileTransferStatus event.

    e.g.<code>
    private static void run29()
    {
    ZipEvents events = new ZipEvents();
    events.ByteProgression += new ByteProgressionEventHandler(events_ByteProgression);
    events.ItemException += new ItemExceptionEventHandler(events_ItemException);
    events.BuildingZipByteProgression += new BuildingZipByteProgressionEventHandler(events_BuildingZipByteProgression);
    events.GatheringZipContentByteProgression += new GatheringZipContentByteProgressionEventHandler(events_GatheringZipContentByteProgression);

    AbstractFile source = new DiskFile( @”D:\temp\fileToZip.txt” );
    AbstractFile dest = new DiskFile( @”D:\temp\fileToZip.zip” );
    ZipArchive archive = new ZipArchive( dest );

    source.CopyTo( events, null, archive, true );
    }

    private static void events_ByteProgression(object sender, ByteProgressionEventArgs e)
    {
    prg1.Position = e.AllFilesBytes.Percent
    }

    //etc…
    </code>

    <a href=”http://doc.xceedsoft.com/products/XceedFileSystem/topic2764.html”>Here </a> is more information from our online help documentation.

    Imported from legacy forums. Posted by André (had 185 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for looking at this Andre. That is simpler than I had been using. Is there a way to use the same format from the FTP example:
    Dim result As IAsyncResult = http://ftp.BeginSendFile(sPath & sMsiName, Nothing, Nothing)
    While Not result.IsCompleted
    Application.DoEvents()
    End While
    So that I can keep the block of code simple while sequentially performing a number of tasks.

    Imported from legacy forums. Posted by Mike (had 218 views)

    User (Old forums)
    Member
    Post count: 23064

    I’m not totally sure I understand your request. On the original request you posted, you use the FileTransferStatus that provides the same information as with the ZipEvents object, except that it is on the AsyncFtpClient (or FtpClient) itself. May be you don’t need to use the async object, if what you want is simply update your progress bar, and you will not need to process the DoEvents loop.

    Imported from legacy forums. Posted by André (had 4172 views)

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