ext Button event Response file garbled,bu in the net button is good

  1. #1

    ext Button event Response file garbled,bu in the net button is good

    Click image for larger version. 

Name:	未命名.jpg 
Views:	116 
Size:	89.7 KB 
ID:	3618

    protected void Button_DirectClick1(object sender, DirectEventArgs e)
        {
            using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))
            {
                //设置压缩密码,经测试设要设置置密码必须第一步设置,再添加文件或者文件夹后设置无效
                // zip.Password = "MyTest";
                //要压缩的文件夹 
                //zip.AddDirectory(Request.PhysicalApplicationPath);
                //还可以再追加多个要压缩的文件夹或文件
                //zip.AddFile(@"c:\1.txt");
    
                zip.AddDirectory(Server.MapPath("Tool"));
                //追加一个说明文档
                zip.AddEntry("说明.txt", "说明内容", Encoding.GetEncoding("gb2312"));
    
                MemoryStream ms = new MemoryStream();
                zip.Save(ms);
                Response.ContentType = "application/zip";
                Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.zip", HttpUtility.UrlEncode("111111")));
                Response.BinaryWrite(ms.ToArray());
                ms.Close();
                ms.Dispose();
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            using (ZipFile zip = new ZipFile(System.Text.Encoding.Default))
            {
                //设置压缩密码,经测试设要设置置密码必须第一步设置,再添加文件或者文件夹后设置无效
                // zip.Password = "MyTest";
                //要压缩的文件夹 
                //zip.AddDirectory(Request.PhysicalApplicationPath);
                //还可以再追加多个要压缩的文件夹或文件
                //zip.AddFile(@"c:\1.txt");
    
                zip.AddDirectory(Server.MapPath("Tool"));
                //追加一个说明文档
                zip.AddEntry("说明.txt", "说明内容", Encoding.GetEncoding("gb2312"));
    
                MemoryStream ms = new MemoryStream();
                zip.Save(ms);
                Response.ContentType = "application/zip";
                Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.zip", HttpUtility.UrlEncode("111111")));
                Response.BinaryWrite(ms.ToArray());
                ms.Close();
                ms.Dispose();
            }
        }
    Help me, thank you, welcome you to come to the Chinese guest
    Last edited by Daniil; Dec 24, 2011 at 8:55 AM. Reason: Please use [CODE] tags
  2. #2
    Hi,

    Please set up
    IsUpload="true"
    for a DirectEvent.

Similar Threads

  1. Replies: 2
    Last Post: Aug 30, 2013, 1:48 AM
  2. Replies: 3
    Last Post: Oct 21, 2011, 4:35 AM
  3. Button clidk event
    By madhu in forum 1.x Help
    Replies: 1
    Last Post: May 10, 2011, 7:39 AM
  4. Replies: 3
    Last Post: Feb 02, 2010, 6:32 PM
  5. [CLOSED] Button event
    By flaviodamaia in forum 1.x Help
    Replies: 3
    Last Post: Oct 24, 2008, 3:52 PM

Posting Permissions