多个图片文件压缩成zip(rar)
通过网页上传文件都服务器
服务器解压文件并获取里面的图片数据
分成一个一个图片文件并保存能做到吗

解决方案 »

  1.   

    你看看这篇文章或许对你有帮助: asp.net中调用winrar实现压缩解压缩
      

  2.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    using Microsoft.Win32;
    using System.Runtime.InteropServices;
    using System.Diagnostics;//该源码下载自www.51aspx.com(51aspx.com)
    namespace TreeRar
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                //递归展示文件目录
                string[] dir = Directory.GetDirectories(Server.MapPath("\\"));
                Response.Write("<table   width=100%   border=1   rules=rows   cellspacing=0   colspacing=0><tr   height=60   bgColor=#339900><td colspan=3 style=\"color=#FFFFFF\">目录列表:</td></tr>");
                for (int i = 0; i < dir.Length; i++)
                {
                    string href = dir[i];
                    href = "http://"+Request.Url.Authority.ToString() + href.Substring(href.LastIndexOf("\\"));
                    Response.Write("<tr     onmouseout=\"this.style.backgroundColor='#ffffff'\"   onmouseover=\"this.style.backgroundColor='#cccccc'\"><td>&nbsp;</td><td>" + dir[i] + "</td><td><a   href=" + href + ">打开</a></td></tr>");
                }
                Response.Write("</table>");
                lbTree.Text = Server.MapPath("\\");
                //   在此处放置用户代码以初始化页面   
            }        //得到当前IP
            private string GetIP()
            {
                string[] IP_Ary;
                string strIP, strIP_list;
                strIP_list = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (strIP_list != null && strIP_list != "")
                {
                    strIP_list = strIP_list.Replace("'", "");
                    if (strIP_list.IndexOf(",") >= 0)
                    {
                        IP_Ary = strIP_list.Split(',');
                        strIP = IP_Ary[0];
                    }
                    else
                    {
                        strIP = strIP_list;
                    }
                }
                else
                {
                    strIP = "";
                }
                if (strIP == "")
                {
                    strIP = Request.ServerVariables["REMOTE_ADDR"];
                    strIP = strIP.Replace("'", "");
                }
                return strIP;
            }
            protected void btnZip_Click(object sender, EventArgs e)
            {
              //压缩
            String my51aspxRar;
            RegistryKey my51aspxReg;
            Object my51aspxObj;
            String my51aspxInfo;
            ProcessStartInfo my51aspxStartInfo;
            Process my51aspxProcess;
            try
            {
                my51aspxReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
                my51aspxObj = my51aspxReg.GetValue("");
                my51aspxRar = my51aspxObj.ToString();
                my51aspxReg.Close();
                my51aspxRar = my51aspxRar.Substring(1, my51aspxRar.Length - 7);
                my51aspxInfo = "a  -r  -ep1 51aspx.rar " + lbTree.Text + @"rar/51aspx.txt "+ lbTree.Text + @"rar";//这里为rar的压缩命令格式(也可以自行扩展)
                my51aspxStartInfo = new ProcessStartInfo();
                my51aspxStartInfo.FileName = my51aspxRar;
                my51aspxStartInfo.Arguments = my51aspxInfo;
                my51aspxStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                my51aspxStartInfo.WorkingDirectory = lbTree.Text + "rar"; ;//获取或设置要启动的进程的初始目录。
                my51aspxProcess = new Process();
                my51aspxProcess.StartInfo = my51aspxStartInfo;
                my51aspxProcess.Start();
                Response.Write("<font color=red>压缩成功</font>");
            }
            catch (Exception ex)
           {
                Response.Write(ex.ToString());
            }        }        protected void btnUnZip_Click(object sender, EventArgs e)
            {
             //解压缩
            String my51aspxRar;
            RegistryKey my51aspxReg;
            Object my51aspxObj;
            String my51aspxInfo;
            ProcessStartInfo my51aspxStartInfo;
            Process my51aspxProcess;
            try
            {
                my51aspxReg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRar.exe\Shell\Open\Command");
                my51aspxObj = my51aspxReg.GetValue("");
                my51aspxRar = my51aspxObj.ToString();
                my51aspxReg.Close();
                my51aspxRar = my51aspxRar.Substring(1, my51aspxRar.Length - 7);
                my51aspxInfo = " X " + lbTree.Text + @"rar/51aspx.rar " + " " + lbTree.Text + @"unRar";
                my51aspxStartInfo = new ProcessStartInfo();
                my51aspxStartInfo.FileName = my51aspxRar;
                my51aspxStartInfo.Arguments = my51aspxInfo;
                my51aspxStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                my51aspxProcess = new Process();
                my51aspxProcess.StartInfo = my51aspxStartInfo;
                my51aspxProcess.Start();
                Response.Write("<font color=red>解压缩成功</font>");
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }        }
        }
    }
      

  3.   

    可以,做的方法有多种,可以调用windows的dll调用自身的zip压缩,也可以用gzip,也可以调用第三方的压缩软件,推荐用windows自带的zip工具
      

  4.   

    网上有Zip Library 的第三方的dll,download一个