Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET ItemDoesNotExistException at EndUpdate

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

    Hello,

    we have update Xceed Zip from V3.6 to V4.3. We pack a folder into a new zip file with optional split the new file.

    The code below works fine with the old version, but when I try it with the new version I get an ItemDoesNotExistException when I call the EndUpdate Method in the finally block. If a do not use the split option, it is also ok.

    Kind regards

    Thomas

     

    		static void Main(string[] args)
    		{
    			Xceed.Zip.Licenser.LicenseKey = "license key";
    			ZipEvents events = new ZipEvents();
     
    			AbstractFile zipFile = new DiskFile("Test.zip");
    			if (zipFile.Exists)
    				zipFile.Delete();
     
    			AbstractFolder sourceFolder = new DiskFolder(@"C:\Program Files\Xceed Components\Xceed Zip for .NET 4.3");
     
    			ZipArchive zip = new ZipArchive(events, null, zipFile);
    			
    			events.ItemProgression += events_ItemProgression;
    			zip.BeginUpdate(events, null);
    			try
    			{
    				// Allow this zip file to span.
    				//zip.AllowSpanning = true;
    				zip.DefaultCompressionLevel = Xceed.Compression.CompressionLevel.Normal;
     
    				//if (this.splitArchive)
    				//{
    				    zip.SplitNameFormat = SplitNameFormat.PkZip;
    				    zip.SplitSize = 1048576;
    				//}
     
    				// Zip this folder's contents
    				sourceFolder.CopyTo(events, null, zip, true);
    			}
    			catch (FileSystemIOException ioEx)
    			{
    				Console.WriteLine(ioEx.ToString());
    			}
    			catch (Exception ex)
    			{
    				Console.WriteLine(ex.ToString());
    			}
    			finally
    			{
    				// Complete the batch modification of this zip file.
    				zip.EndUpdate(events, null);
    				events.ItemProgression -= events_ItemProgression;
    			}
    		}
     
    		static void events_ItemProgression(object sender, ItemProgressionEventArgs e)
    		{
    			Console.Write(".");
    		}
    

    Imported from legacy forums. Posted by Thomas (had 1443 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Thomas,

    If you want to zip the contents of a folder, in this case “C:\Program Files\Xceed Components\Xceed Zip for .NET 4.3“, you will need to use the CopyFilesTo method instead. For example:

    C#

    ———–

    sourceFolder.CopyFilesTo(events, “sourceFolder.CopyFilesTo”, zip, true, true);

    ———–

    For more information, you can refer to our online documentation here.

    Imported from legacy forums. Posted by Marc [Xceed] (had 283 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello Marc,

    yes this works, but with a different result. With CopyTo the folder is included in my zip file, with CopyFilesTo only the files and all subfolders. In this case it is ok for me to create the folder first in the zip and than copy the files to this newly created folder. But why does this method “CopyTo” work in the old version and not in the new one? The documentation you referenced says:

    “Do you only want to copy a specific file or folder? Use the CopyTo method.”

    Thanks

    Thomas

    Imported from legacy forums. Posted by Thomas (had 213 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello Marc,

    Imported from legacy forums. Posted by Thomas (had 217 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello Marc,

    sorry, I have to take back my statement above. It does not work. If a use only the CopyFilesTo method it is ok, but the result is different. If I create a new folder in the zip files with the same name as the source folder and use the CopyFilesTo method to copy the files in the new folder, I get the same exception as before:

    // Zip this folder’s contents
    AbstractFolder destinationFolder = zip.CreateFolder(sourceFolder.Name);
    sourceFolder.CopyFilesTo(events, null, destinationFolder, truetrue);
    
    Thanks for your help
    Thomas

    Imported from legacy forums. Posted by Thomas (had 248 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Thomas,

    I have attached a small sample application that shows how to use the
    CopyTo method with the events to the proper ZipArchive. The sample
    application uses split zips and should be good enough to incorporate it
    into your project.

    Imported from legacy forums. Posted by Marc [Xceed] (had 1303 views)

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