如何在c#中将csv导出为zip文件

时间:2015-02-18 05:19:45

标签: c# asp.net asp.net-mvc csv

我要创建一个CSV并向其写入信息然后下载它。现在我必须以zip格式下载它。

 public  void WriteToCSV(List<DeviceModel> DeviceList)
    {
        string attachment = "attachment; filename=DeviceModel.csv";
        Response.Clear();
        Response.ClearHeaders();
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "text/csv";
        Response.AddHeader("Pragma", "public");
        WriteColumnName();
        foreach (DeviceModel Device in DeviceList)
        {
            WriteDeviceInfo(Device);
        }
      Response.End();
    }

1 个答案:

答案 0 :(得分:1)

您可以使用库:

http://dotnetzip.codeplex.com/