【发布时间】:2015-07-23 18:07:27
【问题描述】:
我正在尝试从数据库中导出 pdf,但我遇到了这个问题
已添加具有相同键的项目
在最后一行 - zip.AddFile(str, "");
那么如何解决这个问题呢?以下是代码:
public static void generateRespondentReport(string startDate, string endDate)
{
List<string> inpatientFileList = generateRespondentReportByQuestionSet(1, startDate, endDate);
List<string> outpatientFileList = generateRespondentReportByQuestionSet(2, startDate, endDate);
List<string> visitorFileList = generateRespondentReportByQuestionSet(3, startDate, endDate);
// timestamp
DateTime now = DateTime.Now;
string FileName = "RespondentReport_" + now.Day + now.ToString("MMM") + now.Year + "_" + string.Format("{0:hh-mm-sstt}", now) + ".zip";
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "application/zip";
response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
// add into zipfile
ZipFile zip = new ZipFile();
foreach (string str in inpatientFileList)
{
zip.AddFile(str, "");
}
foreach (string str in outpatientFileList)
{
zip.AddFile(str, "");
}
foreach (string str in visitorFileList)
{
zip.AddFile(str, "");
}
【问题讨论】:
标签: c# asp.net database dictionary