需引用ICSharpCode.SharpZipLib.Zip.dll
第一步:先写帮助类
public class MyNameTransfom : ICSharpCode.SharpZipLib.Core.INameTransform
{
#region INameTransform 成员
public string TransformDirectory(string name)
{
return null;
}
public string TransformFile(string name)
{
return Path.GetFileName(name);
}
#endregion
}
private void DownloadHelper(IEnumerable<string> filePaths, string zipFileName)
{
//根据所选文件打包下载
MemoryStream ms = new MemoryStream();
byte[] buffer = null;
using (ZipFile file = ZipFile.Create(ms))
{
file.BeginUpdate();
file.NameTransform = new MyNameTransfom();//通过这个名称格式化器&#