Hi, I have a very frustrating issue. Im pulling .pdf files from a Server on the same network and copying them to the DW folder structure.
All connections are working fine and they are being copied. I then zip them and create a .zip, all is good, I can open the zip from the folder and the files within.
The folder gets downloaded to the browser downloads folder, but when I open it I have Windows Error:
"Windows cannot open the folder. The compressed (zipped) Folder '###' is invalid". on a mac the zip converts itself to .cpgz file and loops.
if (files.Any())
{
var temp = System.Web.HttpContext.Current.Server.MapPath("~/Files/System/UserDownloads");
// empty the temp (UserDownloads) folder
System.IO.Directory.EnumerateFiles(temp).ToList().ForEach(f => System.IO.File.Delete(f));
// copy the selected files to the temp (UserDownloads) folder
files.ForEach(f => System.IO.File.Copy(f, System.IO.Path.Combine(temp, System.IO.Path.GetFileName(f))));
List<string> fileList = new List<string>();
while (true)
{
if (files.Count() == fileList.Count())
{
break;
}
fileList = System.IO.Directory.EnumerateFiles(temp).ToList();
}
if (fileList.Count() == files.Count())
{
string attachment = "attachment; filename=TestZipFile.zip";
// System.Web.HttpContext.Current.Response.Clear();
//System.Web.HttpContext.Current.Response.ClearHeaders();
//System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ContentType = "application/zip";
//System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
System.Web.HttpContext.Current.Response.Charset = System.Text.Encoding.UTF8.WebName;
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", attachment);
//System.Web.HttpContext.Current.Response.AddHeader("Pragma", "must-revalidate");
//System.Web.HttpContext.Current.Response.AddHeader("Cache-Control", "must-revalidate");
//System.Web.HttpContext.Current.Response.Write("Test;Test2;Test3");
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Server.MapPath("~/Files/System/UserDownloads"));
Dynamicweb.Content.Files.ZipFile.ZipFolder(dir, "TestZipFile.zip");
System.Web.HttpContext.Current.Response.TransmitFile(System.Web.HttpContext.Current.Server.MapPath("~/Files/System/UserDownloads/TestZipFile.zip"));
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); // instead of Response.End()
}
}
Im using a standard DW web.config and my server is confd correctly (Mime Types etc)
Testing on 2 pure .net applications it works fine and testing with 2 diffrent 3rd party zip .dlls the exact same result, works fine in vanilla and not in DW.
Is DW doing something wild wth the HttpContext here? Is there a setting in DW / web.config I dont know about?
Rgds
Kev