Welcome to the Xceed Community | Help
Community Search  
More Search Options

ItemDoesNotExistException at EndUpdate

Sort Posts: Previous Next
  •  03-29-2012, 7:51 AM Post no. 31929

    ItemDoesNotExistException at EndUpdate

    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(".");
    		}
    
  •  03-29-2012, 2:28 PM Post no. 31930 in reply to 31929

    Re: ItemDoesNotExistException at EndUpdate

    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.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
  •  03-30-2012, 1:46 AM Post no. 31932 in reply to 31930

    Re: ItemDoesNotExistException at EndUpdate

    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

  •  03-30-2012, 2:04 AM Post no. 31933 in reply to 31932

    Re: ItemDoesNotExistException at EndUpdate

    Hello Marc,
  •  03-30-2012, 2:07 AM Post no. 31934 in reply to 31932

    Re: ItemDoesNotExistException at EndUpdate

    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
  •  03-31-2012, 11:34 AM Post no. 31939 in reply to 31934

    Re: ItemDoesNotExistException at EndUpdate

    Attachment: TestProject146835.zip

    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.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.