急!!!
寻求帮助,解决压缩文件名是中文,压缩后变成乱码的问题

解决方案 »

  1.   

    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();
      

  2.   

    我用的VS2003用的是ICSharpCode.SharpZipLib.dll这个压缩DLL
    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();
    }
    }
    }
      

  3.   

    arrFile是啥?按理说如果是已经定义好的名字,加在路径后面是不会有问题的呀
      

  4.   

    string strEntryName =HttpUtility.UrlDecode(item.FullName.Replace(strBaseDir,""))
    关键问题在这句,唉貌似根本实现不了。各位好心人有知道这种问题有实现过的吗?我只想有个依据,知道能不能实现。