有没有解决压缩文件名是乱码问题的? 急!!!寻求帮助,解决压缩文件名是中文,压缩后变成乱码的问题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string strFileName="AllUpLoadFile"; MemoryStream ms = null;Response.ContentType = "application/octet-stream";strFileName = HttpUtility.UrlEncode(strFileName).Replace('+', ' ');Response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName + ".zip");ms = new MemoryStream();zos = new ZipOutputStream(ms);strBaseDir = strAllLoadPath + "\\";addZipEntry(strBaseDir);//这里是进行压缩处理zos.Finish();zos.Close();Response.Clear();for(int a=0;a<arrFile.Count;a++){ string filename = strAllLoadPath+@"\"+arrFile[a].ToString(); if(File.Exists(filename)) { File.Delete(filename); }}Response.BinaryWrite(ms.ToArray());Response.End();Response.Close(); 我用的VS2003用的是ICSharpCode.SharpZipLib.dll这个压缩DLLvoid addZipEntry(string PathStr) { DirectoryInfo di = new DirectoryInfo(PathStr); foreach (DirectoryInfo item in di.GetDirectories()) { addZipEntry(item.FullName); } foreach (FileInfo item in di.GetFiles()) {//new String(filepath.getBytes(),"iso8859-1"); try { FileStream fs = File.OpenRead(item.FullName); byte[] buffer = new byte[fs.Length]; if(buffer.Length<1)continue; fs.Read(buffer, 0, buffer.Length); string strEntryName =HttpUtility.UrlDecodeToBytes(item.FullName.Replace(strBaseDir,"")).ToString(); ZipEntry entry = new ZipEntry(strEntryName); zos.PutNextEntry(entry); zos.Write(buffer, 0, buffer.Length); fs.Close(); } catch(Exception ex) { //ex.ToString(); } } } arrFile是啥?按理说如果是已经定义好的名字,加在路径后面是不会有问题的呀 string strEntryName =HttpUtility.UrlDecode(item.FullName.Replace(strBaseDir,""))关键问题在这句,唉貌似根本实现不了。各位好心人有知道这种问题有实现过的吗?我只想有个依据,知道能不能实现。 TexBox框 Repeater显示效果? viewstate问题 字符串存入数据库之前该如何的处理(进者有分) 求助:当DataList绑定之后。。。。 如何用xsl控制xml格式?如何把xml输出成excel时,可以生成多个sheet?大侠们,快帮帮忙啊!急 大家帮忙看下类似这个网站http://www.d1yh.com/开发成本和技术 高手来看看,关于框架刷新的问题…… .Net 菜鸟求教,我是初学者,还没入门,有很多问题请教各位高手。 初学asp,问个很菜的问题 “sp1234”才能回答的问题? js div显示延迟
MemoryStream ms = null;
Response.ContentType = "application/octet-stream";
strFileName = HttpUtility.UrlEncode(strFileName).Replace('+', ' ');Response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName + ".zip");
ms = new MemoryStream();
zos = new ZipOutputStream(ms);
strBaseDir = strAllLoadPath + "\\";
addZipEntry(strBaseDir);//这里是进行压缩处理
zos.Finish();
zos.Close();
Response.Clear();
for(int a=0;a<arrFile.Count;a++)
{
string filename = strAllLoadPath+@"\"+arrFile[a].ToString();
if(File.Exists(filename))
{
File.Delete(filename);
}
}
Response.BinaryWrite(ms.ToArray());
Response.End();
Response.Close();
void addZipEntry(string PathStr)
{
DirectoryInfo di = new DirectoryInfo(PathStr);
foreach (DirectoryInfo item in di.GetDirectories())
{
addZipEntry(item.FullName);
}
foreach (FileInfo item in di.GetFiles())
{//new String(filepath.getBytes(),"iso8859-1");
try
{
FileStream fs = File.OpenRead(item.FullName);
byte[] buffer = new byte[fs.Length];
if(buffer.Length<1)continue;
fs.Read(buffer, 0, buffer.Length);
string strEntryName =HttpUtility.UrlDecodeToBytes(item.FullName.Replace(strBaseDir,"")).ToString();
ZipEntry entry = new ZipEntry(strEntryName);
zos.PutNextEntry(entry);
zos.Write(buffer, 0, buffer.Length);
fs.Close();
}
catch(Exception ex)
{
//ex.ToString();
}
}
}
关键问题在这句,唉貌似根本实现不了。各位好心人有知道这种问题有实现过的吗?我只想有个依据,知道能不能实现。