在asp.net应用程序中压缩文件夹 [英] compressing a folder with in a asp.net application

查看:104
本文介绍了在asp.net应用程序中压缩文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想使用asp.net将文件夹压缩为.zip.我的网站上有一个包含图像的文件夹.现在,我需要对其进行压缩(ZIP)以对该文件夹进行备份.因此,用户可以zip文件格式从服务器下载它.

如何使用ASP.NET制作ZIP文件夹.

有帮助吗?

在此先感谢

Hi all,

I want to compress a folder as .zip using asp.net. I have a folder contains images in my website. Now i need to compressed it (ZIP) to take backup of that folder. So the user can download it from server in the format of zip file.

how to make ZIP folder using ASP.NET.

any help ?

Thanks in Advance

推荐答案

ASP.NET无法压缩zip.它是生成HTML的引擎.没有某种添加库,C#和VB.NET将无法做到这一点.但是,J#可以做到这一点,关于如何使用J#的文章很多,如果您不在ASP.NET中,则可以使用J#库在C#或VB.NET中做到这一点.
ASP.NET can''t compress zips. It''s an engine for generating HTML. C# and VB.NET can''t do it without some sort of add in library. But, J# can do it, there''s tons of articles on how to use J# and you could use a J# library to do it in C# or VB.NET, if you''re in ASP.NET nor not.




您可以查看这些解决方案
http://forums.asp.net/t/1193746.aspx [ http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx [ http://www.eggheadcafe.com/articles/20050821.asp [
Hi,

You can check these solutions
http://forums.asp.net/t/1193746.aspx[^]
http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx[^]
http://www.eggheadcafe.com/articles/20050821.asp[^]
For each of the solutions there is a function that needed to invoke from your web application, like if you use .NET Zip Library you have to use this code below
ZipFile zip= new ZipFile("MyNewZip.zip"); 
zip.AddDirectory("My Pictures", true); // AddDirectory recurses subdirectories
zip.Save(); 


希望对您有所帮助.


Hope this will help.


ICSHARPziplib库可帮助您压缩文件夹并下载.
通过以下链接可以帮助您压缩文件夹

邮编 [
ICSHARPziplib library helps you to zip a folder and download it.
go through following link which will help you to zip your folder

ZIP ME[^]

and then use following code to download folder

if (File.Exists(szFilePath))
            {
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fInfo.Name);

                HttpContext.Current.Response.AddHeader("Content-Length", fInfo.Length.ToString());
                HttpContext.Current.Response.ContentType = "application/zip";

                HttpContext.Current.Response.TransmitFile(fInfo.FullName);

                HttpContext.Current.Response.End();
                return true;
            }


这篇关于在asp.net应用程序中压缩文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆