Posted on 06/03/2019 09:17:35
Hi Hans
It is only possible from the backend.
Here is some code that you can use that utilizes Dynamicweb.Content.Files namespace (9.5+).
Be aware that this is a security issue if expose this in the frontend for users not logged in. Be careful!
Sub DoDownload()
If Not String.IsNullOrEmpty(_folder) Then
_file = _folder.Substring(_folder.LastIndexOf("/") + 1) + ".zip"
_folder = HttpContext.Current.Server.MapPath(_folder)
Dim fi As New IO.FileInfo($"{_folder}\{IO.Path.GetRandomFileName()}")
For i As Integer = 0 To 10
If fi.Exists Then
fi = New IO.FileInfo($"{_folder}\{IO.Path.GetRandomFileName()}")
Else
Exit For
End If
Next
Try
ZipFile.ZipFolder(New IO.DirectoryInfo(_folder), fi)
Response.Clear()
Response.ContentType = "text/html"
Response.AppendHeader("Content-Disposition", $"attachment; filename=""{_file}""")
Response.TransmitFile(fi.FullName)
Response.Flush()
Finally
fi.Delete()
End Try
Response.Close()
End If
End Sub