Download and open compressed files

Asked

Viewed 60 times

0

Guys I have the following code on an aspx page that compresses files and then downloads them...

 protected void Page_Load(object sender, EventArgs e)
        {

            try
            {
                JuntarArquivosAprovados(startPath);

                CompactarArquivos();

                DeletarConteudoPasta();

                FileInfo file = new FileInfo(zipPath);

                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;

                response.ClearContent();
                response.Clear();

                response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name + ";");
                response.WriteFile(file.FullName);
                response.Flush();
                response.Close();


            }
            catch (Exception ex)
            {
                throw ex;
            }


        }

He downloads the compressed files right...but when I open I get the message that the files are damaged and does not open...I have another project that uses the SAME code in a Webservice (asmx) and I can open these files quiet... Does anyone have any idea why ?

  • And if you just compact and try to open the file on the same server, it opens normal?

  • opens normal yes

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.