IT researcher
IT researcher

Reputation: 3304

Zip a folder having subfolders using zipstorer class

I am using ZIpstorer class library to compress files. I am able to zip a file by calling zip.AddFile procedure. But I want to zip folders which has subfolders too. So the resulting zip file should have folder and subfolder structure inside the zip file normally. I am not able to do it. if i process each file by looping all folders and sub folders and then if call zip.Addfile then it will result in zip file with all the files inside it without a directory structure.

So how can i zip a folder using Zipstorer class . What changes i have to do?

Upvotes: 0

Views: 957

Answers (1)

CodeCaster
CodeCaster

Reputation: 151594

You can use (back)slashes for the _filenameInZip (sic) parameter to add files in a directory in the zip:

zip.Addfile(,,"directory/filename.txt",);

Or

zip.Addfile(,,"directory\\filename.txt",);

Upvotes: 1

Related Questions