Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Verify the created zip

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

    Hey,

    In code I create a zip file on a location like C:\test.zip.
    Then I want to check the zip if its valid (no errors occurred).
    Then i copy the file from C\:test.zip to D\:test.zip.
    Then i check/verify again.

     Now i just creating the zip and copy it.

    But how can i verify it?

    Thanks

    Imported from legacy forums. Posted by Insider (had 2759 views)

    User (Old forums)
    Member
    Post count: 23064

    There is no method to do this automatically.  The only option you have is to open a stream on the zip archive, and unzip files, without doing anything with the stream.  This will minimize memory using for the operation, and will ensure the archive’s integrity if no exception is thrown.

    e.g.:

          AbstractFile zipFile = new DiskFile( @”D:\Temp\test.zip” );
          ZipArchive archive = new ZipArchive( zipFile );
          foreach( ZippedFile file in archive.GetFiles( true ) )
          {
            //you can log the file name for example if you want to keep a trace of what you are doing
            System.Diagnostics.Debug.WriteLine( file.Name );
            try
            {
              using( Stream fileStream = file.OpenRead() )
              {
                byte[] buffer = new byte[ 32768 ];
                int bytesRead = 0;
                while( ( bytesRead = fileStream.Read( buffer, 0, buffer.Length ) ) > 0 )
                {
                }
              }
            }
            catch( Exception e )
            {
              System.Diagnostics.Debug.WriteLine( e.ToString() );
            }
          }

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

    User (Old forums)
    Member
    Post count: 23064

    It seems to work, but i need to set the encryption password.

    How can i set the password?

    Thanks

    Imported from legacy forums. Posted by Insider (had 1813 views)

    User (Old forums)
    Member
    Post count: 23064

    Use the overloaded method that takes an password on file.OpenRead().

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

    User (Old forums)
    Member
    Post count: 23064

    Hi there,

     Do you have a VB.net version of the code above?

     

     Thanks

    Imported from legacy forums. Posted by I (had 1437 views)

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