Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Adding a file to a specific folder within a zip file

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

    I have read thorugh the documents, and search this forum, and cannot find an example on how to add a file to a specific directory within a zip file.

     

    Everytime I try, I get the exception error, “Not a valid Win32 Filetime”…

     This is what I tried:

     DiskFile customzip = new DiskFile(<path to file>)

    all the way up to 

     Diskfile filetoinsert = new DiskFile(<pathtofile>)

    filetoinsert.CopyTo(new ZipArchive(<pathtozip>),<directorytoaddto>),true); 

     

    It was something like that, but I still cannot find out what I am doing wrong.

     Please Help,

     Thank you!

    Imported from legacy forums. Posted by Jason (had 3045 views)

    User (Old forums)
    Member
    Post count: 23064

    You need to create a ZippedFile with the right path and filename, and then use this ZippedFile to copy the disk file to the archive.

    e.g.:

          //The zip archive to which we want to add a file
          AbstractFile zipFile = new DiskFile( archivePathAndName );
         
          //The file on disk to add to the archive
          AbstractFile fileToAdd = new DiskFile( someFilePath );     
         
          //Create the file in the archive that will be in the right folder
          ZippedFile newFileInArchive = new ZippedFile( zipFile, @”\Folder\” + fileToAdd.Name );

          //Do the actual copy of the disk file to the archive
          fileToAdd.CopyTo( newFileInArchive, true );
     

     

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

    User (Old forums)
    Member
    Post count: 23064

    Hey Thanx!

     

    I will try it out!

     Jason

     

    Imported from legacy forums. Posted by Jason (had 2817 views)

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