2024年4月2日发(作者:)
步骤
1)先引用 ;
2).cs文件引入
using ;
using ;
using ums;
using ;
using ;
3)代码
#region 下列代码为压缩并下载代码
ZipOutputStream zos = null;
String strBaseDir = "";
void dlZipDir(string strPath, string strFileName)
{
MemoryStream ms = null;
tType = "application/octet-stream";
strFileName = ode(strFileName).Replace('+', ' ');
der("Content-Disposition", "attachment; filename="
strFileName + ".zip");
ms = new MemoryStream();
zos = new ZipOutputStream(ms);
strBaseDir = strPath + "";
addZipEntry(strBaseDir);
();
();
();
Write(y());
+
();
}
void addZipEntry(string PathStr)
{
DirectoryInfo di = new DirectoryInfo(PathStr);
foreach (DirectoryInfo item in ectories())
{
addZipEntry(me);
}
foreach (FileInfo item in es())
{
FileStream fs = ad(me);
byte[] buffer = new byte[];
(buffer, 0, );
string strEntryName = e(strBaseDir, "");
ZipEntry entry = new ZipEntry(strEntryName);
tEntry(entry);
(buffer, 0, );
();
}
}
PRotected void Button2_Click(object sender, EventArgs e)
{
string userPath ="D:华海实训()各级账号和密码";
dlZipDir(userPath, "华海实训()服务账号");
}
#endregion
更多信息请查看spx" target=_blank>IT技术专栏


发布评论