loniczip


                if (!Directory.Exists(Server.MapPath(webUploadFile)))
                {
                    Directory.CreateDirectory(Server.MapPath(webUploadFile));
                }
                //string path = Server.MapPath(webUploadFile + filename);//获取存储的目标地址
                using (var zip = new ZipFile(Encoding.Default))
                {
                    //判断原文件是否存在
                    if (System.IO.File.Exists(oldfilename))
                    {
                        //压缩文件
                        zip.AddFile(oldfilename, "");
                    }
                    int index = filename.LastIndexOf(".");
                    string suffix = filename.Substring(index);
                    filename = filename.Replace(suffix, ".zip");
                    //获取存储的目标地址
                    string path = Server.MapPath(webUploadFile + filename);
                    zip.Save(path);
                }               
                oldfilename = webUploadFile.Replace('\\', '/') + oldfilename;
                file = null;
                //替换文件名
                queryStr = queryStr.Replace(oldfilename, webUploadFile.Replace('\\', '/') + filename);

你可能感兴趣的:(java,前端,服务器)