Is it possible to create a zip file using Sitecore FileUtil.ZipFiles
where the files to be added are from the Media Library items?
1 Answer
No, it's not possible wit FileUtil
only.
What you can do is:
- Add a reference to
Sitecore.Zip.dll
- Use
Sitecore.Zip.ZipWriter
class like that:
using (ZipWriter zw = new ZipWriter(FileUtil.MapPath("/test.zip")))
{
var mediaItem = new MediaItem(item);
zw.AddEntry(mediaItem.Name + "." + mediaItem.Extension, mediaItem.GetMediaStream());
}
Remember that your IIS process user must have write access to the folder where you want to create the zip file.