Home › Forums › .NET libraries › Xceed Zip & Real-Time Zip for .NET › Adding a file to a specific folder within a zip file
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>)
It was something like that, but I still cannot find out what I am doing wrong.
Imported from legacy forums. Posted by Jason (had 3045 views)
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.
//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)
I will try it out!
Imported from legacy forums. Posted by Jason (had 2817 views)