This project is read-only.

DotNetZip doesn't zip all files

Feb 7, 2015 at 9:35 PM
Edited Feb 7, 2015 at 9:36 PM
Hi all!
I trying to zip files in mvc application
 public class ZipResult : ActionResult
        public List<string> FilePaths { get; private set; }
        public string Filename { get; private set; }

        public ZipResult(List<string> path, string filename)
            FilePaths = path;
            Filename = filename;

        public override void ExecuteResult(ControllerContext context)
            if (context == null)
                throw new ArgumentNullException("context");

            var response = context.HttpContext.Response;
            response.ContentType = "application/gzip";
            using (var zip = new ZipFile())
                var cd = new ContentDisposition
                    FileName = Filename,
                    Inline = false
                response.Headers.Add("Content-Disposition", cd.ToString());
And after that i using
public ActionResult DownloadAsZip()
//given the f_list from db..

return new ZipResult(f_list.Select(c=>Path.Combine(Server.MapPath("~/App_Data/UserFiles"),c.GenFileName)).ToList(), "");
The output zip file was created successfully, but I dont see all files which I given in zip result.
Please help me in this issue.

Feb 7, 2015 at 10:51 PM
Edited Feb 7, 2015 at 10:52 PM
I trying to rename extension file to rar, and I see the my other files, but name of this files include (in my directory) russian symbols, and in rar i see this symbols replaced to '???' string. I am trying to open it and got the error
'!   C:\Users\User\Downloads\UM Consult_02-08-2015-00_45_42.rar: Невозможно создать ???? 1_5c51062d8c9c433eb6c0b26824569afe.docx
    Синтаксическая ошибка в имени файла, имени папки или метке тома.
!   C:\Users\User\Downloads\UM Consult_02-08-2015-00_45_42.rar: Попытка исправить неверное имя файла
!   C:\Users\User\Downloads\UM Consult_02-08-2015-00_45_42.rar: Переименование ???? 1_5c51062d8c9c433eb6c0b26824569afe.docx в ____ 1_5c51062d8c9c433eb6c0b26824569afe.docx
Feb 7, 2015 at 11:10 PM
Sorry guys, I found the link,
and add
zip.AlternateEncoding = System.Text.Encoding.UTF8;
zip.AlternateEncodingUsage = ZipOption.AsNecessary;
after that i download file in rar format, and all is ok, in zip format the utf-8 filenames shows wrong.