Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET System.IO.EndOfStreamException when zipping to StreamFile

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

    I have the following method to copy contents of one folder to another:

    public void CopyContents(AbstractFolder src, AbstractFolder dest, bool recurse, bool replace)
    {
    //NOTE: The CopyFilesTo method does not copy empty folders,
    // so we must use iterate through items instead
    if (recurse)
    {
    foreach (FileSystemItem item in src.GetItems(false))
    {
    item.CopyTo(dest, replace);
    }
    //src.CopyFilesTo(dest, recurse, replace);
    }
    else
    {
    src.CopyFilesTo(dest, false, replace);
    }
    }

    If dest is a ZipArchive around a StreamFile created from a MemoryStream, I get the following exception when copying files wih the iterating CopyTo method. The first call suceeds, but then the second fails.

    System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Xceed.Zip.ZipIOException: An IO exception occurred while reading from or writing to the zip file.
    Type: Xceed.Zip.ZipArchive
    FullName: \
    Zip file: SFF14676090:\SF36117529 —> System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
    at System.IO.__Error.EndOfFile()
    at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
    at System.IO.BinaryReader.ReadUInt16()
    at Xceed.Zip.EndHeader.ReadFromStream(BinaryReader reader)
    at Xceed.Zip.EndHeader..ctor(BinaryReader reader)
    at Xceed.Zip.ZipHandler.ReadEndHeader(BinaryReader reader, ZipStream stream)
    — End of inner exception stack trace —
    at Xceed.FileSystem.FileSystemItem.CopyTo(FileSystemEvents events, Object userData, AbstractFolder destinationFolder, Boolean replaceExistingFiles)
    at Xceed.FileSystem.FileSystemItem.CopyTo(AbstractFolder destinationFolder, Boolean replaceExistingFiles)
    at Ajlsoft.Decision.Storage.FileManager.CopyContents(AbstractFolder src, AbstractFolder dest, Boolean recurse, Boolean replace) in C:\home\work\ndecision\src\Decision.Storage\FileManager.cs:line 240
    at Ajlsoft.Decision.Server.StorageManager.CheckoutProject(String name) in C:\home\work\ndecision\src\Decision.Server\StorageManager.cs:line 144
    at Ajlsoft.Decision.Server.StorageManager.Checkout(String name, StorageType type) in C:\home\work\ndecision\src\Decision.Server\StorageManager.cs:line 68
    at StorageService.Checkout(String name, StorageType type) in c:\home\work\ndecision\web\App_Code\StorageService.cs:line 32
    — End of inner exception stack trace —

    Am I doing this incorrectly, or is this an issue with the Xceed library.

    Josh

    Imported from legacy forums. Posted by jjohnson (had 2812 views)

    User (Old forums)
    Member
    Post count: 23064

    The following code works fine :

    private static void run()
    {
    ZipArchive archive = new ZipArchive( new StreamFile( new MemoryStream() ) );

    AbstractFolder source = new DiskFolder( @”D:\Temp” );

    foreach( FileSystemItem item in source.GetItems( true ) )
    {
    Console.WriteLine( item.FullName.ToString() );
    item.CopyTo( archive, false );
    }

    foreach( FileSystemItem item in archive.GetItems( true ) )
    {
    Console.WriteLine( item.FullName.ToString() );
    }
    }

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

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